Page 1 of 1

360° compass image

Posted: 2018-08-01T06:02:10-07:00
by fabkzo
Hi ,

Would it be easy to create this type of compass with imagemagick ?
https://commons.wikimedia.org/wiki/File ... 0_(en).svg
I don't find any topic on the way to create it; can someone guide me to make it ?

Best regards,

Re: 360° compass image

Posted: 2018-08-01T06:54:41-07:00
by snibgo
Very easy:

Code: Select all

magick "Compass_360_(en).svg" out.png

Re: 360° compass image

Posted: 2018-08-01T08:25:57-07:00
by fabkzo
Thanks for reply but -well- sure I haven't been clear;
I want to display compass informations on top or bottom of rectilinear photos ( and/or spherical ones) depending on their horizontal field of view and azimuth , calculated and taken from exif datas; which is the hardest? making it polar ( I then reproject it with hugin ) or as a ruler ? Making it on the fly would also permit me to change the style.
I'm used to make it with inkscape - very easily ; do you confirm that's the only way?

Re: 360° compass image

Posted: 2018-08-01T09:19:02-07:00
by fmw42
Perhaps you should provide an example of what you are trying to do with your input images and your output image. Or at least an example of what you would like for the output.

Re: 360° compass image

Posted: 2018-08-01T09:36:36-07:00
by snibgo
I often do jobs like this by writing a simple program that generates SVG. But this can be done entirely in IM, like this:

Code: Select all

%IMG7%magick ^
  -size 500x500 xc:White ^
  -fill Black ^
  ( xc:None ^
    -draw "rectangle 249,20 251,70" ^
    -duplicate 35 ^
    -distort SRT 1,%%[fx:t*10] ^
  ) ^
  ( xc:None ^
    -gravity North ^
    -pointsize 15 ^
    -duplicate 35 ^
    -annotate 0 %%[fx:t*10] ^
    -distort SRT 1,%%[fx:t*10] ^
  ) ^
  -compose Over -layers Merge ^
  simp_compass.png
(Windows BAT syntax. For bash, use \ for line ends and don't double the %%.)

Image
I've done only the major gridlines, and the numbers go the wrong way round, but hopefully you can see the idea.

I start with an empty canvas (which isn't strictly necessary). Then I make 36 images with a small rectangle, which is the marker at the north point, but rotate each (with "-distort SRT") according to its number multipled by ten degrees. Similarly for the text numbers. Finally, I merge all the images.

Re: 360° compass image

Posted: 2018-08-01T15:49:39-07:00
by fabkzo
@snibgo many thanks -and that's the good way for numbers;

But your code, copied with bash syntax as your recommendations, give me that :

Image

This time I use ImageMagick 6.9.7-4 Q16 x86_64 20170114 on Ubuntu studio 18.04, Linux 4.15.0-29-lowlatency

I've tested many variations, without success to remove the black lines. This is the code in my terminal, without end of lines (are they really important?);

Code: Select all

convert -size 500x500 xc:White -fill Black \( xc:None -draw "rectangle 249,20 251,70" -duplicate 35 -distort SRT 1,%[fx:t*10] \) \( xc:None -gravity North -pointsize 12 -duplicate 35 -annotate 0  %[fx:t*10] -distort SRT 1,%[fx:t*10] \) -compose Over -layers Merge test-compas.png 

Re: 360° compass image

Posted: 2018-08-01T15:59:55-07:00
by snibgo
After "-fill Black", insert "-virtual-pixel None".

EDIT: No, chopping a command into lines is not important to IM. I do it to make the command easier for humans to read and understand.