Page 1 of 1

creating a "product"

Posted: 2013-02-20T13:37:58-07:00
by holden
Hey all, I'm trying to figure out a good way to do this, any input is appreciated. I need a way to create a template (actually many kinds) for print purposes, but for example lets say a 4"x6" with .25" borders. So, being that we would want it at 300ppi, it would start at 1200x1800px. Next the borders, so they would be 75px wide. Now I need to fit an image of varying resolution into the leftover middle "hole," either scaling up or down depending on the initial resolution to 300dpi. I am figuring out how to create the appropriately proportioned image already, I just need some smart input on how to go about this in a clean way. Thanks.

*Edit options could be generating the output image on the fly or creating templates to composite into, or perhaps something better

Re: creating a "product"

Posted: 2013-02-20T14:04:19-07:00
by snibgo
So the dimensions within the border are 1200-150 = 1050 pixels by 1800-150 = 1650 pixels. Your input images may not have this aspect ratio. In that case, do you want to (a) trim part of the image away, (b) keep the entire image by adding more white border or (c) change the aspect ratio of the image?

The solution would include the "-resize" command in one of its forms. Then you might add a border, or simply centre it on a 1200x1800 white canvas. Something like this:

Code: Select all

convert -size 1800x1200 xc:pink ( in.png -resize 1650x1050 ) -gravity center -composite out.png
I have used a pink background so I can easily see the boundary of the image.

See http://www.imagemagick.org/script/comma ... ptions.php

Re: creating a "product"

Posted: 2013-02-22T07:28:45-07:00
by holden
Thanks for the reply, I will give that a try. Also,there are different resizing algorithms, is the default good for both upscaling and downscaling? I imagine I will have to run a sharpening process as well.

Re: creating a "product"

Posted: 2013-02-22T08:14:47-07:00
by snibgo
For me, the default settings for enlarging and reducing are fine. viewforum.php?f=22 has discussions of non-default settings.

When the input is a photograph, a final sharpening is generally beneficial, with a sigma somewhere near 1.

Re: creating a "product"

Posted: 2013-02-22T12:10:22-07:00
by fmw42
If I follow this thread, resizing alone will preserve the aspect ratio of the input and so may not fit into the area desired. You would need either to resize normally and use -extent to fill in with your color or resize using the ^ option and center crop the image. Either way, it will not hurt to add that to your command if the resize turns out to be correct. If you use ! option, then the image may be distorted but will fit exactly.

See
http://www.imagemagick.org/script/comma ... p#geometry
http://www.imagemagick.org/script/comma ... php#extent
http://www.imagemagick.org/script/comma ... s.php#crop
http://www.imagemagick.org/Usage/thumbnails/#pad
http://www.imagemagick.org/Usage/thumbnails/#cut

Re: creating a "product"

Posted: 2013-02-22T12:25:50-07:00
by holden
Thanks snibgo, that code seems to be exactly what I need. :D

@fmw42- yes that is my next step, the -extent part. Some people want to have odd sized images on a certain print size without cropping. Thanks for the links and advice.

*as a side note I may have found a bug, when using the crop operator without coordinates, eg. 4x6 vs. 4x6+0+0, you get weird output file names, usually output-0.jpg, output-1.jpg, up to 5, and no output.jpg. Also doing the crop by % generates hundreds of temp files it seems, even on smallish <1000px image (this could be dependent on coords as well, I stopped trying it this way).

Re: creating a "product"

Posted: 2013-02-22T13:02:50-07:00
by snibgo
For the crop feature (not a bug), see http://www.imagemagick.org/script/comma ... s.php#crop

Re: creating a "product"

Posted: 2013-02-26T17:55:38-07:00
by anthony
holden wrote: *as a side note I may have found a bug, when using the crop operator without coordinates, eg. 4x6 vs. 4x6+0+0, you get weird output file names, usually output-0.jpg, output-1.jpg, up to 5, and no output.jpg. Also doing the crop by % generates hundreds of temp files it seems, even on smallish <1000px image (this could be dependent on coords as well, I stopped trying it this way).
That is a feature. Without a offset, crop will generate multiple image tiles.
http://www.imagemagick.org/Usage/crop/#crop_tile
As a result of this IM then needs to save multiple images.
In GIF you would get a single image of all the tiles, for PNG and JPEG separate files as that format can only hold one image per file.
See Adjoin - writing multiple images
http://www.imagemagick.org/Usage/files/#adjoin