Yuriy-Svetlov / compress-images

Minify size your images. Image compression with extension: jpg/jpeg, svg, png, gif. NodeJs
https://www.npmjs.com/package/compress-images
MIT License
598 stars 79 forks source link

20 MB JPEG Compression returning error : Unrecognized input file format #43

Closed jasmalmk closed 4 years ago

jasmalmk commented 4 years ago

While trying to compress 20 MB file, I am Getting an error like Unrecognized input file format --- perhaps you need -targa, Also tried other algorithms but working.

Yuriy-Svetlov commented 4 years ago

Hi @jasmalmk ! Thank you for your alert!

Which algorithm did you use? jpegtran, mozjpeg, webp, guetzli, jpegRecompress, jpegoptim, tinify

Show your code.

Yuriy-Svetlov commented 4 years ago

Can you give me this image?

jasmalmk commented 4 years ago

Hi @jasmalmk ! Thank you for your alert!

Which algorithm did you use? jpegtran, mozjpeg, webp, guetzli, jpegRecompress, jpegoptim, tinify

Show your code.

I used all algorithm except tinyfy

jasmalmk commented 4 years ago

Can you give me this image?

Sorry I cant provide that image

Following are the full error message.

{ Error: Command failed: E:compress-images-master\node_modules\mozjpeg\vendor\cjpeg.exe -quality 60 -outfile build/img/my_post_images_1/132319PPL-ATT.JPEG src/img/my_post_images_1/132319PPL-ATT.JPEG Unrecognized input file format --- perhaps you need -targa

at ChildProcess.exithandler (child_process.js:294:12) at ChildProcess.emit (events.js:198:13) at maybeClose (internal/child_process.js:982:16) at Socket.stream.socket.on (internal/child_process.js:389:11) at Socket.emit (events.js:198:13) at Pipe._handle.close (net.js:606:12) killed: false, code: 1, signal: null, cmd: 'E:\compress-images-master\node_modules\mozjpeg\vendor\cjpeg.exe -quality 60 -outfile build/img/my_post_images_1/132319PPL-ATT.JPEG src/img/my_post_images_1/132319PPL-ATT.JPEG' }

Yuriy-Svetlov commented 4 years ago

@jasmalmk You do not have the correct image, or this is not the image.

Yuriy-Svetlov commented 4 years ago

@jasmalmk And also, perchance, your image contains virus or exploit.

jasmalmk commented 4 years ago

@semiromid thanks for your information, I am not sure about your points, This was an image from iPhone (Safari 13.0 / iPhone OS 13.3.1), which seems to be perfect. I have checked all files like this iPhone having size greater than 15 MB all returns same error. I have tried same image with imagemin Its working.

Yuriy-Svetlov commented 4 years ago

@jasmalmk

You do would be can try use https://developers.google.com/speed/webp/ , without usage compress-images?

jasmalmk commented 4 years ago

@jasmalmk

You do would be can try use https://developers.google.com/speed/webp/ , without usage compress-images?

Really thank for your information. You save my time. This is the first time I am deeply looking to WebP and this is what i exactly i need. For the reported issue i found something common for all image, which processes for RotateFlip by code. Find the code i have used (C#), and also this code made my image size increasing 50% or more .

Image img = Image.FromStream(postedFile.InputStream); foreach (var prop in img.PropertyItems) { if (prop.Id == 0x0112) //value of EXIF { int orientationValue = img.GetPropertyItem(prop.Id).Value[0]; RotateFlipType rotateFlipType =GetOrientationToFlipType(orientationValue); img.RotateFlip(rotateFlipType); img.Save(path); return true; } }

private static RotateFlipType GetOrientationToFlipType(int orientationValue) { RotateFlipType rotateFlipType = RotateFlipType.RotateNoneFlipNone; switch (orientationValue) { case 1: rotateFlipType = RotateFlipType.RotateNoneFlipNone; break;***************; return rotateFlipType; }

Yuriy-Svetlov commented 4 years ago

@jasmalmk

Nevertheless, if you have the opportunity, share your image.