Talk:JPEGhack

From ThorxWiki
Jump to: navigation, search

Here is the script used to create the image.

It has useful examples of the following:

  • adding captions in lolcat style (imagemagick - convert)
  • cropping (jpegtran)
  • dropping (jpegtran)
  • adding exif comments (exiftool)
#!/bin/bash
JPEGTRAN="/home/nemo/bin/jpegtran"

$JPEGTRAN -crop 1600x1024+0+32 -outfile cropped.JPG source.JPG

# make the macro in imagemagick
convert cropped.JPG -quality 100 \
    -comment "jpeghi" \
    -font ~/lib/fonts/TTF/ttfonts/impact.ttf -pointsize 160 \
    -fill grey75 -strokewidth 16 -gravity northwest \
    -stroke black \
    -annotate +48+0 "UR IMAG\nKWALITEE" \
    -stroke none \
    -annotate +48+0 "UR IMAG\nKWALITEE" \
    -gravity southeast -pointsize 208 \
    -stroke black \
    -annotate +64+0 "MAI\nSUFFA" \
    -stroke none \
    -annotate +64+0 "MAI\nSUFFA" \
    caption.JPG


for i in {1,2,3,4,5,6,7,8,9,10,15,20,50,90} ; do convert -quality $i caption.JPG q$i.jpg  ; ls -l q$i.jpg ; done

cp caption.JPG tmp.jpg

$JPEGTRAN -crop 1600x80+0+144 -outfile q50crop.jpg q50.jpg
$JPEGTRAN -drop +0+144 q50crop.jpg -outfile tmp50.jpg tmp.jpg
echo -n "1"

$JPEGTRAN -crop 1600x80+0+224 -outfile q20crop.jpg q20.jpg
$JPEGTRAN -drop +0+224 q20crop.jpg -outfile tmp20.jpg tmp50.jpg
echo -n "2"

$JPEGTRAN -crop 1600x80+0+304 -outfile q15crop.jpg q15.jpg
$JPEGTRAN -drop +0+304 q15crop.jpg -outfile tmp15.jpg tmp20.jpg
echo -n "3"

$JPEGTRAN -crop 1600x80+0+384 -outfile q10crop.jpg q10.jpg
$JPEGTRAN -drop +0+384 q10crop.jpg -outfile tmp10.jpg tmp15.jpg
echo -n "4"

$JPEGTRAN -crop 1600x80+0+464 -outfile q9crop.jpg q9.jpg
$JPEGTRAN -drop +0+464 q9crop.jpg -outfile tmp9.jpg tmp10.jpg
echo -n "5"

$JPEGTRAN -crop 1600x80+0+544 -outfile q8crop.jpg q8.jpg
$JPEGTRAN -drop +0+544 q8crop.jpg -outfile tmp8.jpg tmp9.jpg
echo -n "6"

$JPEGTRAN -crop 1600x80+0+624 -outfile q7crop.jpg q7.jpg
$JPEGTRAN -drop +0+624 q7crop.jpg -outfile tmp7.jpg tmp8.jpg
echo -n "7"

$JPEGTRAN -crop 1600x80+0+704 -outfile q6crop.jpg q6.jpg
$JPEGTRAN -drop +0+704 q6crop.jpg -outfile tmp6.jpg tmp7.jpg
echo -n "8"

$JPEGTRAN -crop 1600x80+0+784 -outfile q5crop.jpg q5.jpg
$JPEGTRAN -drop +0+784 q5crop.jpg -outfile tmp5.jpg tmp6.jpg
echo -n "9"

$JPEGTRAN -crop 1600x80+0+864 -outfile q4crop.jpg q4.jpg
$JPEGTRAN -drop +0+864 q4crop.jpg -outfile tmp4.jpg tmp5.jpg
echo -n "a"

$JPEGTRAN -crop 1600x80+0+944 -outfile q1crop.jpg q1.jpg
$JPEGTRAN -drop +0+944 q1crop.jpg -outfile tmp1.jpg tmp4.jpg
echo "b"

$JPEGTRAN -opt -prog -outfile prefinal.JPG tmp1.jpg

# what exif XMP tags can we write?
# exiftool -listw -XMP-dc:All
# select of those, plus a few extra (-Author, -copyright and -usercomment)
exiftool \
    -Creator="Nemo Thorx <jpeghack@nemo.house.cx>" \
    -Date=1975:04:14 \
    -Description="experimental multi-quality JPEG. See http://wiki.thorx.net/wiki/JPEGhack" \
    -Rights="Nemo Thorx (CC-by-nc-sa)" \
    -Subject="experimental multi-quality JPEG"\
    -Title="UR IMAG KWALITEE MAI SUFFA" \
    -Author="Nemo Thorx <jpeghack@nemo.house.cx>" \
    -copyright="Nemo Thorx (CC-by-nc-sa)" \
    -usercomment="experimental multi-quality JPEG. See http://wiki.thorx.net/wiki/JPEGhack" \
    prefinal.JPG

mv prefinal.JPG kwalitee.JPG

# avg size is about equiv to having done:
convert caption.JPG -quality 72 qtest.jpg
jpegtran -opt -prog -outfile qtest.JPG qtest.jpg


ls -o *.JPG

rm *.jpg

exit
Personal tools
Namespaces

Variants
Actions
Navigation
meta navigation
More thorx
Tools