Re: Converting images with padding or cropping on left and right




* Tuxedo <tuxedo@xxxxxxxxxxxxxx> wrote:

I have a simple shell procedure that batch converts original jpeg's in
various sizes into thumbnail copies, maximum 75 pixels in height:

for i in *.jpg
do convert -quality 70 -geometry x75 $i ../img/`basename $i .jpg`.jpg;
done

When a resulting thumbnail image become less than 100 pixels wide I'd like
to add padding on left and right in some solid color, making the jpeg
including the solid area, to exactly 100 pixels wide.

If however a resulting thumbnail is wider than 100 pixels, I'd like it
cropped equally, or to the nearest pixel, on the left and right edges, so
that it becomes exactly 100 pixels wide.

This is like placing the resulting 75 pixes tall image in the center
of a canvas which is exactly 100x75 pixels, and discarding the excess area
if any.

I'm not sure if this can be done with the Image Magick toolset alone, and
if not, is there an easy way to do this using PerlMagick?

This is easily done using -border/-crop on the command line, or with
PerlMagick using Border/Crop methods.

--
Lars Haugseth

"If anyone disagrees with anything I say, I am quite prepared not only to
retract it, but also to deny under oath that I ever said it." -Tom Lehrer
.



Relevant Pages

  • How to create and draw into a white empty Image
    ... I created some thumbnails from pictures - they all have a size of up to ... 80 pixels in width or height (if it is a square pic, ... Pictures that are smaller shall have a white border to fill up the size ... where I want to draw my thumbnail into. ...
    (microsoft.public.dotnet.framework)
  • Re: What are these blue and white dots
    ... A thumbnail of the file can be seen here: ... Where you can look at a small abstract of the EXIF data to the right ... Might be hot pixels, which often show up as bright, colored blobs of blue, ...
    (rec.photo.digital)
  • Converting images with padding or cropping on left and right
    ... When a resulting thumbnail image become less than 100 pixels wide I'd like ... to add padding on left and right in some solid color, ... including the solid area, ...
    (comp.lang.perl.modules)
  • Re: Help: Image::Magick::Thumbnail
    ... > thumbnail. ... > It creates an image where the biggest size is 50 pixels. ... Do you want the smallest dimension of the image to be scaled ...
    (comp.lang.perl.modules)