Problem with -size and -resize and tiff

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?".
Post Reply
forenhopper

Problem with -size and -resize and tiff

Post by forenhopper »

Hi,

convert.exe img.jpg -resize 354x413 -size 354x413 xc:white -compress LZW -depth 8 -colorspace RGB -type TrueColor result.tiff

I get a Image with 354x307. Thats ok. The image was resized proportional. But i need a Image with the size 354x413 and white Backgroundcolor. Imagick makes only one Imageresize.

Where is my failure?
forenhopper

Re: Problem with -size and -resize and tiff

Post by forenhopper »

solved the problem by my own:

convert.exe (img.jpg -resize 354x413 ) -size 354x413 xc:white -gravity center +swap -composite -compress LZW -depth 8 -colorspace RGB -type TrueColor img.jpg img.tiff
forenhopper

Re: Problem with -size and -resize and tiff

Post by forenhopper »

another Problem, my Images are now all only 72dpi. How can i hold my dpi Value? The dpi changes from Image to Image
User avatar
fmw42
Posts: 25562
Joined: 2007-07-02T17:14:51-07:00
Authentication code: 1152
Location: Sunnyvale, California, USA

Re: Problem with -size and -resize and tiff

Post by fmw42 »

I guess you will have to reset it with -density
User avatar
anthony
Posts: 8883
Joined: 2004-05-31T19:27:03-07:00
Authentication code: 8675308
Location: Brisbane, Australia

Re: Problem with -size and -resize and tiff

Post by anthony »

As you 'swapped' the images, the new canvas image is teh destination and as such it is the one with the meta-data that is kept!

Rather than compositing your image onto a canvas, use -extent instead. That will use a 'clone' of the original image for the canvas and thus preserve density and other meta-data information.

Code: Select all

convert.exe img.jpg -resize 354x413 \
        -background white -gravity center -extent 354x413 \
        .....   img.tiff
Also see Image Padding in Thumbnails for information on sizing an image to fit a specific 'area'.
Anthony Thyssen -- Webmaster for ImageMagick Example Pages
https://imagemagick.org/Usage/
Post Reply