thumbnails generation 

Go to a directory that contains lots of graphics files, and type the following:

convert 'vid:*jpg' catalog.jpg

This command generates a thumbnail index named catalog.jpg. Beneath each thumbnail graphic, you'll find the file's name and size, as well as the image's dimensions. The thumbnails are neatly organized against a gray background.

catalog generation 

rm *0000.jpg *0000.JPG
convert -resize 80x -label %f `ls imgp*.jpg` miff:- | montage - -geometry +6+6 -shadow -texture granite: .catalog.jpg
convert -resize 80x -label %f `ls DSC00*.JPG` miff:- | montage - -geometry +6+6 -shadow -texture granite: .catalog.jpg

From http://www.imagemagick.org/Usage/montage/

# save separate images for each page generated, by suppling a '%d' for the frame/scene/page number of each image filename.
montage  font_*.gif  -tile 4x1  -geometry +2+2  multi_%d.gif
# you don't actually need a frame to generate image shadows
montage balloon.gif medical.gif present.gif shading.gif \
            -tile x1  -shadow  -geometry +5+5  -background lightblue \
            shadow_noframe.jpg
# You don't have to use a "-frame" when labeling thumbnails. The labels are not shadowed
montage -label '%f'  balloon.gif medical.gif logo: present.gif shading.gif \
           -tile x1 -shadow -geometry '60x60+2+2>'  label_shadow.jpg

image (re)compressing tool 

Newsgroups:  gmane.linux.debian.user
Date:        Sun, 19 Nov 2006 17:49:39 +0100
> Is there any command line tool that can take a jpeg file and re-compress it
> with a new compress level/factor?

I think convert can do what you want:

convert -quality XX old.jpg new.jpg

where XX is the quality (in percent) that you want for new.jpg; lower quality = higher compression ratio with stronger jpeg artefacts.

Florian Kulzer

image (re)compressing tool 

> thank you Florian & Sven for the swift respond.
>
> yes, the -quality option of convert/mogrify is what I'm looking for.
>
> I was just blindly searching their man pages with some keywords but didn't
> notice that the man pages are actually less than a pageful. :-)

The man page also suggests visiting: file:///usr/share/doc/imagemagick/index.html

in your browser. The webpage has a link to command line options. This has proved to be very helpful to me in the past.

H.S.

Resize the image 

$ identify cover-back.jpg
cover-back.jpg JPEG 380x555 DirectClass 171kb 0.020u 0:01
$ convert -resize 176x cover-back.jpg new.jpg
$ identify new.jpg
new.jpg JPEG 176x257 DirectClass 47kb 0.000u 0:01

documented on: 2005.03.25

Stretch the image canvas 

Which tools under Linux do you know that can stretch the image canvas? I need to stretch small images to a bigger unanimous dimension. How can I do that?

I meant to stretch the *canvas*, the image remains the same size. E.g, stretching a 300x300 image to 600x400, but the image stays intact, still 300x300 (and better in the middle of the image), but the canvas is stretched. So identify will returns 600x400, but the images looks the same.

Answer:

the best approach is to create the desired blank image, then

composite -gravity center odd_sized blank_image unanimous_sized

No distinction necessary, no calculation/awk needed.

Also check out:

you can use a Viewport Crop, and flatten the result onto a background color.

convert -size 200x200 hatching.jpg -thumbnail '100x100>' \
        -gravity center  -crop 120x120+0+0\! \
        -background skyblue  -flatten    pad_view.gif

Another method to pad out an image is to overlay the thumbnail onto a background image (actual image, solid color or tile) that is the right size, in this case the 128x128 "granite:" built-in image.

convert -size 200x200 hatching.jpg -thumbnail '100x100>' \
        granite: +swap -gravity center -composite pad_compose.gif

Stretch the image canvas 

convert -frame 400x600+0+0 -mattecolor white  infile outfile

Use -frame to set the desired size of the canvas. Set the bevel size to zero so you don't see them.

Use the mattecolor to force in the background color you want.

Dan Espen @telcordia.com

Stretch the image canvas 

Hi, thank you all who have answered my question.

> See, the results are extraordinary big, not as supposed 520x130. why?

I solve it finally:

$ identify *.jpg
testimg.trim.jpg JPEG 98x130 DirectClass 8-bit 8497b 0.0u 0:01
$ convert -frame 520x130+0+0 -mattecolor white testimg.trim.jpg
testimg.new.jpg
$ convert -frame 211x0+0+0 -mattecolor white testimg.trim.jpg
testimg.new2.jpg
$ identify *.jpg
testimg.new.jpg[1] JPEG 1138x390=>569x195 DirectClass 8-bit 11723b 0.0u 0:01
testimg.new2.jpg[2] JPEG 520x130 DirectClass 8-bit 9091b 0.0u 0:01
testimg.trim.jpg[3] JPEG 98x130 DirectClass 8-bit 8497b 0.0u 0:01

See, now "new2" has the right size, whereas "new" not. The trick is that the "<width>x<height>" if for the *single border* size, not the finial output size.

Cropping an image 

*Tags*: image convert crop cut

The 'convert' command has a '-crop' command.

-crop widthxheight{+-}x{+-}y{%}

The width and height give the size of the image that remains after cropping, and x and y are offsets that give the location of the top left corner of the cropped image with respect to the original image.

If this canvas and position image information is not wanted, then you can use the special "+repage" operator to reset the page canvas and position to match the actual cropped image.

If you want to crop say the right hand side of a image out, use the the -gravity option.

Note that while the size can be a percentage the offset will always be in pixels. You can not provide an offset as a percentage of the image size.

To specify the amount to be removed, use -shave instead. To remove pixels from the interior of an image, use -chop.

Merge 2 (jpeg) images 

Newsgroups: comp.os.linux.misc
Date: 2001-10-06 09:12:46 PST
>is there a linux shell tool which is able to merge two (jpeg)images
>(for example to add watermarks to my images)?
combine (part of ImageMagick)

PoD

Merge 2 (jpeg) images 

combine is now named as composite (ImageMagick Version: 4:5.4.4.5)

ImageMagick Examples — Alpha Compositing http://www.imagemagick.org/Usage/compose/ Best of the best!

Merge 2 (jpeg) images 

man Imagemagick
man combine
man convert

These programs have a lot of options, but at least some of them make sense. Also, you can use Gimp from the command line if you need to do anything more complicated than Imagemagick can handle. However, doing really complex things with Gimp from the command line apparently requires learning Scheme.

Matt G

Merge 2 (jpeg) images 

djpeg image.jpg > image.ppm
djpeg watermark.jpg > watermark.ppm
pnmarith -add image.ppm watermark.ppm | cjpeg > new.jpg

This assumes, of course, that you are doing a true "watermark,", that is a translucent design in the background of the image.

If you want a logo, you could do something like:

djpeg logo.jpg > logo.ppm
pnmpaste logo.ppm xoffset yoffset image.ppm | cjpeg > new.jpg

Mike Castle @netcom.com