On Wed, Jun 13, 2012 at 12:47 PM, Rob Owens <row...@ptd.net> wrote:
> On Wed, Jun 13, 2012 at 12:45:13PM +0200, Randall wrote:
>>
>> is it possible to have all messages received by the mailinglists MTA
>> scanned for pictures and have these automatically scaled to a
>> default size before its being redistributed to the receivers on the
>> mailinglist and subsequently the forum.
>>
> craigslist.org seems to do this when you upload pictures of the item
> you're selling.  I'm not sure how they do it, but I imagine they use the
> mogrify command from imagemagick:
>
> mogrify -resize 800x600 somefile.jpg
>
> This will overwrite the original somefile.jpg with an 800x600 version of
> somefile.jpg
>
> This gets tricky, because what if the original is taller than it is
> wide?  The above command will distort the image.
>
> You can also:
>
> mogrify -resize 30% somefile.jpg
>
> This gives you the correct aspect ratio every time, but what if the
> original image was already small?
>
> Anyway, some food for thought.

The ImageMagick "identify" command could be used on the image to
gather statistics (such as pixel size) do some math on it, and feed
that back to mogrify, giving you some consistency in output.

Example:

cbell@circe:~$ identify testimage.jpg
testimage.jpg JPEG 4752x3168 4752x3168+0+0 8-bit DirectClass 5.706MB
0.000u 0:00.000
cbell@circe:~$

Grab field 3, do some math to determine aspect ratio, compare the
current resolution against your target, figure out the new size for
the image, feed that back to mogrify to resize it correctly.

Want something smaller than 800x600?

In the above, the image is 4752 x 3168.  We want the image to be
smaller than 800x600.  We need to decrease the image size by the
larger of 4752/800 or 3168/600.  These are 5.28 and 5.94 respectively.
 So we need to decrease the image to 16.8% of its current size
(1/5.94).

cbell@circe:~$ mogrify -resize 16.8% testimage.jpg
cbell@circe:~$ identify testimage.jpg
testimage.jpg JPEG 798x532 798x532+0+0 8-bit DirectClass 239KB 0.000u 0:00.010
cbell@circe:~$

Goal achieved.

-- 
Chris


--
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/CAOEVnYs-R�UzbkdQtRQpD8Xn_uGFE=qus5f+txaajovjr...@mail.gmail.com

Reply via email to