h2non / imaginary

Fast, simple, scalable, Docker-ready HTTP microservice for high-level image processing
https://fly.io/docs/app-guides/run-a-global-image-service/
MIT License
5.5k stars 455 forks source link

embed error when using pipeline with resize + watermark on small image #395

Open ianjosephwilson opened 2 years ago

ianjosephwilson commented 2 years ago

I'm trying to migrate some old image resizing code I have that has a set of fixed sizes that are blindly cut from the originals. Some of the images are really old and probably should never be cut but the system isn't smart.

My pipeline operations looks like this:

[{"operation": "resize", "params": {"width": 950}}, {"operation": "watermark", "params": {"text": "www.123.example.com", "noreplicate": true}}]
curl 'http://localhost:8090/pipeline?file=images%2Foriginal%2F64%2F64316f9775cc421f8383033a301177c7&operations=%5B%7B%22operation%22%3A+%22resize%22%2C+%22params%22%3A+%7B%22width%22%3A+950%7D%7D%2C+%7B%22operation%22%3A+%22watermark%22%2C+%22params%22%3A+%7B%22text%22%3A+%22www.123.example.com%22%2C+%22noreplicate%22%3A+true%7D%7D%5D' -o ana.jpg

I get the following error:

{"message":"Error while processing the image: embed: bad dimensions","code":1}

It seems to be a problem with the size of the image and the size of the watermark but I don't see how I can scale the watermark text down with the image size. It seems that images less than 300/400 px seem to be a problem.

ianjosephwilson commented 2 years ago

After further testing my 949(w)x759(h) image starts working at sizes 500, 600, 700 starting at 100 and above but my 120x141 image never works and always results in that error.