I have a jpeg file downloaded off a website that runs ASP.NET problem is that the file contains following part that makes GM Spit this warning:
Error: Command failed: gm identify: No decode delegate for this image format (/tmp/gmIc3ey2).
gm identify: Request did not return an image.
at ChildProcess.onExit (/home/novelty/Desktop/api_service/node_modules/gm/lib/command.js:318:17)
at ChildProcess.emit (node:events:511:28)
at maybeClose (node:internal/child_process:1098:16)
at ChildProcess._handle.onexit (node:internal/child_process:304:5) {
code: 1,
signal: null
}
Error: Command failed: gm identify: No decode delegate for this image format (/tmp/gmKoGJsp).
gm identify: Request did not return an image.
at ChildProcess.onExit (/home/novelty/Desktop/api_service/node_modules/gm/lib/command.js:318:17)
at ChildProcess.emit (node:events:511:28)
at maybeClose (node:internal/child_process:1098:16)
at ChildProcess._handle.onexit (node:internal/child_process:304:5) {
code: 1,
signal: null
}
Sample Image: https://cdn.discordapp.com/attachments/1113934560254754897/1115865687710236823/1.jpeg1 (I had to change the extension to prevent any change in the file)
The file is being able to read by gimp, photohop etc. only issue that It cannot be read/manipulated using gm, is there's a way to force gm to work with such malformed image?
attempting to resize this image also fails example code (does not resize the image just to show the error):
import gm from 'gm'
const imageData = await (await fetch('https://cdn.discordapp.com/attachments/1113934560254754897/1115865687710236823/1.jpeg1')).arrayBuffer()
gm(Buffer.from(imageData))
.identify(
(error, info) => console.log(info)
)
the image causes this error, I tried splitting the buffer from the <!DOCTYPE part but still it didn't work
I believe for some unknown reason gm fails to detect the Image format and just throws up, I'm sure this file is valid except for some weird random HTML at the bottom appended by the ASP.NET, I attempted to remove it using buffer split(https://www.npmjs.com/package/buffer-split) but that didn't fix it and it's probably irrelevant considering other software can read the file fine.
The weird part in file is: enter image description here