How To Resize A Moving Painting Using Command-Line Tools
Occasionally, I remove to resize an image. For instance, Google+ refuses to piece of job my favorite portrait every minute my profile picture. The argue is that the portrait is smaller than the minimum requirement of 250 x 250 pixels.
To scale the image, I tin opt for a GUI tool such every minute Pinta. This postal service explores the scaling of pictures using command-line tools.
We volition piece of job tools such every minute convert in addition to identify from the ImageMagick package. To install ImageMagick on Debian:
$ sudo apt-get update $ sudo apt-get install imagemagick
identify
To know the electrical flow dimension of the image, run the identify command:
$ position portrait1.jpg portrait1.jpg JPEG 320x237 320x237+0+0 8-bit DirectClass 20.5KB 0.000u 0:00.000
The outcome includes the paradigm width in addition to meridian inward the break of pixels (320x237). From that, nosotros know that the image's meridian is below the minimum requirement.
convert
To scale the meridian dimension to 250 pixels:
$ convert -resize x250 -strip portrait1.jpg myProfile.jpg $ position myProfile.jpg myProfile.jpg JPEG 338x250 338x250+0+0 8-bit DirectClass 35.2KB 0.000u 0:00.000
Note that the width is scaled upwards proportionally (to 338 pixels). To manually scale the width using convert, specify -resize 338x on the dominance line.
$ convert -resize 338x -strip portrait1.jpg myProfile1.jpg $ position myProfile1.jpg myProfile1.jpg JPEG 338x250 338x250+0+0 8-bit DirectClass 35.2KB 0.000u 0:00.000
You tin also piece of job convert to wearing clothing upwards the picture, for instance, add together a 3-pixel greyish frame.
$ convert -resize x250 -strip -frame 3x3 -mattecolor "#999999" portrait1.jpg framedProfile.jpg
If optimizing file size is a major concern, yous should investigate the piece of job of the -quality option.
In general, paradigm character in addition to file compression conduct maintain an inverse relationship: higher paradigm character agency lower file compression. The character value ranges from i (lowest character in addition to highest compression) to 100 (highest character precisely lowest compression).
$ convert -resize x250 -quality 95 -strip portrait1.jpg myProfile95.jpg $ $ ls -al myProfile*.jpg -rw-r--r-- i peter peter 19267 May 31 16:11 myProfile95.jpg -rw-r--r-- i peter peter 35160 May 31 15:31 myProfile.jpg
Specifying a character of 95 (as compared to the default) resulted inward a 45% reduction of the output file size. Some experimentation amongst character values is needed to accomplish the remainder of minimal file size in addition to acceptable paradigm quality.
0 Response to "How To Resize A Moving Painting Using Command-Line Tools"
Post a Comment