View Single Post
Old 03-23-2023, 09:33 AM   #3
stutz
Junior Member
stutz began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Mar 2023
Device: kobo clara hd
Thanks. I'll try and see if I can write a plugin then. In the meanwhile, I managed to write a shell script to convert a file how I want (requires imagemagick and jpegtran). It turned out that my e-reader doesn't read exif metadata, so I have to actually rotate the image.

Code:
#!/bin/sh

infile="$1"
outfile="$2"

croparea=$(convert "$infile" -fuzz 10% +repage -trim -format '%[fx:w]x%[fx:h]+%[fx:page.x]+%[fx:page.y]\n' info:)
jpegtran -outfile tmp.jpg -progressive -arithmetic -crop $croparea "$infile"

read -r width height << EOF
$(identify -format "%w %h\n" $outfile)
EOF
if [ $width -gt $height ]; then
    jpegtran -outfile "$outfile" -progressive -arithmetic -rotate 90 tmp.jpg
fi
rm -f tmp.jpg
stutz is offline   Reply With Quote