I’ve searched around and can’t find this but it seems like someone must have created this already. I am hoping to find a self-hosted image resizer app. I frequently need to take photos from my phone (etc…) and make them small enough to post online.
For instance, my lemmy instance (lemm.ee) only allows images in posts if they are smaller than 500KB but my phone’s photos are always larger than that.
In a perfect world, I could just browse to a local server app, upload an image, select a size to resize it to, hit Go and then download the smaller image. It doesn’t have to allow any other editing and it shouldn’t store images long-term. I want to self-host so I don’t have to upload my images to random web sites I know nothing about.
I would be happy with a FOSS desktop app I can install in linux too, but then I couldn’t access it from my phone. The Android apps I found for this either look scammy or include tons of ads.
Anyone know of such a thing? Thanks!
EDIT - UPDATE:
Thank you for the great suggestions. I’ve installed Image Toolbox on my Android phone and that looks great. It both has a ton of tools but also makes this resizing task very straightforward. Not sure how I never found that before.
But for my desktop, I started writing a PHP app to run in my existing nginx web server. It runs the suggested ffmpeg command under the hood, and since I am the only user on this server, this works very well for me.
That’s working now so I am going to tweak a few things and then use it for a while. (Before anyone asks, I started based on the Python recs here, but couldn’t get it working (PIP couldn’t add Flask because PIP couldn’t find PIP???) and so switched to PHP since my local server was already using that from another home-made app. This (PHP) was not as hard as I was afraid it would be, with help from Duck Duck Go’s AI chat bot.
I used my php app to shrink this file!
Thank y’all - this is resolved now.
Yah, thanks. In a pinch, I’ve been using GIMP but as you say, there’s a lot to it and a lot of steps to this simple process.
I’m going to see if a AI tool can help hack together a simple web page. If I do, I’ll share the code I end up with somewhere.
You should really just do this without any web application. Just use a background shell script that does the resizing automatically on any image file that you dump into a certain folder. I have similar stuff set up for naming and sorting based on geo location data.
You can even make this work for mobile by having the folder that the script runs on synced to your phone. You take a pic on your phone, it gets synced to your desktop, converted by the script, synced back to your phone.
This way it also works if you want to share large amount of photos (of a trip or event or something)
Thanks for the script approach idea!
Two quick ideas on possible approaches:
Static page route. You can just write some Javascript to load the image from a file input in HTML, draw it resized to a canvas (based on an input slider or other input element), then save the canvas to an image. (There might even be simpler approaches if I wasn’t stupidly tired right now…) This can be done in a single file (HTML with embedded JS – and CSS if you want to style it a little) that you toss on any web server anywhere (e.g. Apache, nginx, whatever). Should work for JPEG, PNG, and probably WebP – maybe other regular image types too. Benefit: data never needs to leave your device.
Process on server route. Use Python with a simple web server library (I usually opt for tornado for stuff like this, but flask or cherrypy or similar would probably work). Set up a handler for e.g. an HTTP POST and either pass the image into a library like Pillow to resize it or shell out to ImageMagick as others have suggested. (If you want to do something clever with animated GIFs you could shell out to ffmpeg, but that’d be a fair bit trickier…) The image can be sent back as the response. Be careful about security if you take this route. Probably want some kind of login in front of it, and run it in a VM or some other secure environment – especially if you’re using AI to kludge it together…
Best of luck and let me know if you need any help. Will probably have some time this weekend if you can’t get it on your own. Happy hacking!
Ooooh! I started down the PHP path and that’s already working but now I like this idea of using JS and canvas more so I am going to go research that next. I have an nginx server running so this could work. (I wonder if this is how https://squoosh.app/ works since they claim it’s all client-side too?)
Great suggestion, I didn’t know was possible so thanks very much! 👍