lossless-jpg / data Goto Github PK
View Code? Open in Web Editor NEWSome JPEG operations can be lossless if you are using the right software. This project aims to inform your choice.
License: MIT License
Some JPEG operations can be lossless if you are using the right software. This project aims to inform your choice.
License: MIT License
You can use imagemagick's fuzz and blur to automatically crop / trim jpegs scans using jpegtran:
#/usr/bin/env bash
for f in ./*.jpg; do
fuzzFactor=5
box=$(convert "$f" -virtual-pixel edge -blur 0x15 -fuzz "$fuzzFactor"% -trim -format '%[fx:w]x%[fx:h]+%[fx:page.x]+%[fx:page.y]' info:)
if [ $(echo $box | awk -F'[x+]' '{print (0+$3)+(0+$4)}') != 0 ]; then
jpegtran -copy all -crop "$box" -outfile ${f%.jpg}_out.jpg "$f"
fi
done
That is, imagemagick is used not to modify the files but to output the cropbox which is then passed to jpegtran to do the actual (semi-lossless) cropping. Imagemagick and jpegtran conveniently use the same geometry format to specify crop boxes so we only need to check there's actually something to cut (using awk to add the crop values to see if they sum greater than 0) before passing the box to jpegtran.
It's a very useful trick when going through scanned material.
Anyhow, the the fuzzFactor depends on saturation and often needs tweaking. i.e. 5% is what I personally found safe with unprocessed scans off desktop scanners. But, if lucky, you might get away with as much as 15% if the contrast between the blacks and whites really stands out. However, it's rarely the case...
Incidentally, jpegtran crop helper is nice.
p.s. This method was derived from a lossy method found in the imagemagick v6 docs.
I saw @nicolas-raoul post about partical JPEG recompression.
I think Jpegcoll is one of the solution for your requirement.
If you are interested in another lossless operations, you should check Betterjpeg.
Almost apps which have JPEG lossless operations are based on IJG code.
These apps are listed here.
But these apps have only rotate, flip and crop as lossless operation except above two probably.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.