johansatge / jpeg-autorotate Goto Github PK
View Code? Open in Web Editor NEW๐ธ Node module to rotate JPEG images based on EXIF orientation.
Home Page: https://www.npmjs.com/package/jpeg-autorotate
License: MIT License
๐ธ Node module to rotate JPEG images based on EXIF orientation.
Home Page: https://www.npmjs.com/package/jpeg-autorotate
License: MIT License
hello my friend, i was happy to find this simple tool
however when i ran this on my images, even though it reported that it correctly detected which images have the botched orientation, and says that they were processed -- the images appear totally unchanged, the cli tool appears to have had no affect
here is my bash session
Chase@Chase-PC MINGW64 ~/Desktop/Lonnie Photoshoot 2
$ jpeg-autorotate ./*.jpg
./20190602_125845.jpg: Orientation already correct
./20190602_125957.jpg: Orientation already correct
./20190602_130009.jpg: Orientation already correct
./20190602_130014.jpg: Orientation already correct
./20190602_130026.jpg: Orientation already correct
./20190602_130101.jpg: Orientation already correct
./20190602_130104.jpg: Orientation already correct
./20190602_130230.jpg: Orientation already correct
./20190602_130231.jpg: Orientation already correct
./20190602_130233.jpg: Orientation already correct
./20190602_130235.jpg: Orientation already correct
./20190602_130239.jpg: Orientation already correct
./20190602_130242.jpg: Orientation already correct
./20190602_130243.jpg: Orientation already correct
./20190602_130246.jpg: Orientation already correct
./20190602_130247.jpg: Orientation already correct
./20190602_130250.jpg: Orientation already correct
./20190602_130252.jpg: Orientation already correct
./20190602_130253.jpg: Orientation already correct
./20190602_130254.jpg: Orientation already correct
./20190602_130255.jpg: Processed (Orientation was 6) (Quality 100%)
./20190602_130256.jpg: Processed (Orientation was 6) (Quality 100%)
the last two images, after the processing, appear totally unchanged
just now i have used git to confirm that not a single byte has changed
how can i get jpeg-autorotate
to save the upright processed image?
I can see post 200 images, it becomes very slow.
jpeg-autorotate upload/20170220204242-image.jpg
upload/20170220204242-image.jpg: EACCES: permission denied, open 'upload/20170220204242-image.jpg'
I don't want to use sudo. Any Idea?
We sometimes have images that needs more then the default 512 MB of memory that is set by the maxMemoryUsageInMB option for jpeg-js (https://github.com/eugeneware/jpeg-js#decode-options). It would be awesome if we could increase this value as an option to this module so we can use this module even for bigger images.
Maybe I'm just missing something to get it right, but it seems like the tool does not support glob paths am I right there? I tried the following:
jpeg-autorotate input/**/*.{jpg,jpeg,JPG,JPEG}
but keep getting:
> jpeg-autorotate input/**/*.{jpg,jpeg,JPG,JPEG}
input/**/*.{jpg,jpeg,JPG,JPEG}: Could not read file (ENOENT: no such file or directory,
open 'C:\Test\input\**\*.{jpg,jpeg,JPG,JPEG}')
What am I doing wrong? Hints are very welcome ;-)
Basically, I have image info in base64 encoded. so, I'm converting the base64 to buffer by using the following code
const thumbnailBuffer = await Buffer.from(thumbnailBase64, "base64");
The Buffer im passing looks like this to the rotate() function.
buffer <Buffer 75 ab 5a 8a 66 a0 7b fa 67 81 b6 ac 7b ae 22 54 13 91 c3 42 86 82 80 00 00 03 52 52 11 14 80 00 00 3b c0 00 00 3b c2 00 80 00 00 25 44 85 3b 80 00 00 ... 8626 more bytes>
Below is the error when Im executing.
An error occurred when rotating the file: Could not read EXIF data (Error: 'load' gots invalid file data.)
(node:21457) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'width' of undefined
at PDFDocument.image (/home/user/***/***/***/node_modules/pdfkit/js/mixins/images.js:27:17)
at WriteStream.<anonymous> (/home/user/***/***/***/***/***/file.js:192:11)
at processTicksAndRejections (internal/process/next_tick.js:81:5)
(node:21457) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:21457) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Done in 2.17s.
Please LMK if Im doing any wrong.
When trying to install the module with node 10.4.1 it produces the following error:
error [email protected]: The engine "node" is incompatible with this module. Expected version "9.3.0".
error Found incompatible module
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.
PS C:\Projects\project> node -v
v10.4.1
Npm Run Build fro React apps fail to minify the code, likely (according to the README) because it wasn't precomiled to ES5
Thanks for the awesome plugin!
Any thoughts on adding an option to reapply exif data after rotate?
I can see one would have to update the orientation tag.
Just saw that you have an option to regenerate the thumbnail. Awesome.
I couldn't find a reference to it in the readme - does this lib work in the browser?
This module looks awesome and I'd like to use it to sort my billion photos.
However, I'm concerned in the loss of quality in my pictures. I know that the JPG format allows lossless rotation (https://www.betterjpeg.com/lossless-rotation.htm)
Is it what your module does? Or does your module rotate the full bit plane then re-encode?
This is because the colors
library is allowed to be updated to 1.4.1/1.4.2, introducing this mess.
Pinning it to 1.4.0
should fix it for now. Consider switching to an alternative.
As seen in #11, the existing tests are not enough.
Let's try to introduce visual testing, to make sure the resulting image has been rotated/flipped correctly.
Possible workflow:
I tried using this lib in nodejs project as I need to add images to PDF document. I had issues with images that had rotation defined in EXIF metadata. So I tested this lib with images from https://www.daveperrett.com/articles/2012/07/28/exif-orientation-handling-is-a-ghetto
I used their images that are for testing in their git repo.
I see issues with orientations 5 and 7:
EXIF_Content_A5_xmas.pdf
Wildcard and glob support in the CLI appears to be only reading the first file encountered. If I have a directory with the following files:
and I run jpeg-autorotate test*.jpg, it will correctly process the first item and then no more.
How to use this for image which is being fetched from online source, I am not looking for saving the file on disk before rotating.
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.