Making sure image has at least given dimensions after resize

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: Making sure image has at least given dimensions after resize

Post by fmw42 »

I cannot access your posted image. If from dropbox, it needs to made sharable.

Pad which image? The watermark or the background? Do you need to adjust the background to have the same aspect as the watermark? Is that this issue?
Mihamix
Posts: 13
Joined: 2018-01-21T06:12:33-07:00
Authentication code: 1152

Re: Making sure image has at least given dimensions after resize

Post by Mihamix »

fmw42 wrote: 2018-02-06T12:22:05-07:00 I cannot access your posted image. If from dropbox, it needs to made sharable.

Pad which image? The watermark or the background? Do you need to adjust the background to have the same aspect as the watermark? Is that this issue?
The image is sharable... Here is a different link.

The original image (which becomes the background if I'm correct) needs to be padded on the top and the bottom, to make it big enough for the watermark to fit.
ImageMagick 7.0.7 Q16 HDRI x64 DL on Win Srv 2008 R2
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Making sure image has at least given dimensions after resize

Post by fmw42 »

OK. Here is my code in unix syntax for the first image

Code: Select all

magick \
\( /Users/fred/desktop/PZImages/WM_m.png \
    -set option:dim "%[fx:(w>h)?650*w/h:650]x%[fx:(w>h)?650:650*h/w]" -resize "%[dim]" \) \
\( /Users/fred/desktop/PZImages/original/17201-33020@02.jpg -print "%f\n" \
    -fuzz "10%" -trim +repage  -rotate "90<" -resize "%[dim]" \
    -background white -gravity center -extent "%[dim]" \) \
+swap -gravity center -compose over -composite \
/Users/fred/desktop/PZImages/fred_results2/17201-33020@02.jpg

Here are my results for each image

Image

Image

Image

Image

Image
Mihamix
Posts: 13
Joined: 2018-01-21T06:12:33-07:00
Authentication code: 1152

Re: Making sure image has at least given dimensions after resize

Post by Mihamix »

fmw42 wrote: 2018-02-06T14:11:03-07:00 OK. Here is my code in unix syntax for the first image

Code: Select all

magick \
\( /Users/fred/desktop/PZImages/WM_m.png \
    -set option:dim "%[fx:(w>h)?650*w/h:650]x%[fx:(w>h)?650:650*h/w]" -resize "%[dim]" \) \
\( /Users/fred/desktop/PZImages/original/17201-33020@02.jpg -print "%f\n" \
    -fuzz "10%" -trim +repage  -rotate "90<" -resize "%[dim]" \
    -background white -gravity center -extent "%[dim]" \) \
+swap -gravity center -compose over -composite \
/Users/fred/desktop/PZImages/fred_results2/17201-33020@02.jpg

Here are my results for each image

Image

Image

Image

Image

Image
Perfect, many thanks - I'll port it to Windows :)
I really do appreciate your help and your drive to find the exact solution!
ImageMagick 7.0.7 Q16 HDRI x64 DL on Win Srv 2008 R2
Post Reply