I use Open Live Writer to create images for my blog. More specifically, I have some old posts that use the decorative borders on images ad I want to add new images that match that style; using Open Live Writer lets me have that style. I’m starting to dislike that my page is full of 600×600 pixel PNG images because they are large and take a while to download. WordPress, for some crazy reason, doesn’t have a way to force uploaded images to be JPG images and so far, plug-ins that say they compress or “optimize” image files don’t seem to be able to copy or replace these large PNG images.

I found someone who wrote code to make thumbnails as jpeg images but the image on the page is not a thumbnail. It took a bit of debugging to figure out what data to use but I finally go it working. Now when an image is uploaded and WordPress attempts to make thumbnails and images in alternate sizes, my code copies the files to JPG files of the same path and name. I can then add references to these smaller files to my special old pages (since their content is edited as HTML because the formatting unique to those pages). Here is my code in all of it’s just-now-working ugliness:

I will need to go find the original source of this code because I want to credit the original developer who wrote much of it. I moved things around so I could just call a function to do the copy. I also had to change things because the original file does not have the same metadata as the “size” files. But the image copy is from that other developer.