Reduce the number of commands

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Reduce the number of commands

Post by fmw42 »

Pete,

I don't think you need to subtract 1 from w and h.

this works fine for me in Unix (using my string --- note Anthony's original method used the file approach)

infile="hatching_orig.jpg"
drawcmd=`convert $infile -define jpeg:size=300x300 -thumbnail "300x300>" \
-format "roundrectangle 1,1 %[fx:w],%[fx:h] 25,25" info:`
convert $infile -thumbnail "300x300>" \
\( +clone -threshold "100%" -fill white -draw "$drawcmd" \) \
-alpha off -compose CopyOpacity -composite \
-background none -compose Over -gravity center -extent 300x300 \
thumbnail_rounded_in_one2.png


I would have done it this way myself using copyopacity, but I was just following Anthony's example. He knows more about compose methods. I really am not too familiar with DstIn, myself.

Note, your point about resetting the -compose method to over, is important in things like -extent and -border and the like, even -blur, when you use other compose methods in parenthesis. Seems as though -respect parenthesis does not respect this aspect. Good catch.

Similarly, there have been times that I have also had to reset the geometry (using +geometry) in similar like situations where -respect parenthesis is not honoring that.


Fred
el_supremo
Posts: 1015
Joined: 2005-03-21T21:16:57-07:00

Re: Reduce the number of commands

Post by el_supremo »

I don't think you need to subtract 1 from w and h
While I was testing this with logo: as input, it was giving me a one pixel black line along the top of the image and subtracting one fixed it. Also, the description of roundrectangle says that those values are the coordinates of top left and bottom right corners of a rectangle which in this case would be 0,0 w-1,h-1.

Pete
Sorry, my ISP shutdown all personal webspace so my MagickWand Examples in C is offline.
See my message in this topic for a link to a zip of all the files.
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Reduce the number of commands

Post by fmw42 »

Also, the description of roundrectangle says that those values are the coordinates of top left and bottom right corners of a rectangle which in this case would be 0,0 w-1,h-1
Pete,

I think you are right about using w-1 and h-1 per your comment about the lower right corner of the image's coordinates. My mistake. It also smoothes/rounds the corners better than with w and h. Thanks for catching that.

Fred
Post Reply