I have over 6000 image files that I need to change the extensions from .png to .jpg If you have a PHP script that can do this or know of a script I could use please help. Thank you in advance
You know that changing a file-extension doesn't actually do anything to the file, right? It'll still be .png-files. So, good questions to ask would be "why?". Why do you need to change the extensions? If it's for uploading, you might want to test with one file first, just to see if it will upload, since if the uploader is limited to .jpg-files, and coded properly, changing the file-extension won't do anything...
Google will help you https://www.google.com/#q=convert%20png%20to%20jpg%20with%20php I see many results from StackOverflow when have many PHP experts.
...and if you just need it to save your site's bandwidth, perhaps a desktop-software like Irfanview is the better tool for this bulk conversion.
Thank you for taking the time to write back. Actually I do need the files to stay .png The reason why I want to change them to jpg is mainly for mobile devices to be able to view them, I have a window phone and a kindle that do not show the images.
I did try google search before I came here. I found hundreds of links but none of them worked. There are at least a couple dozens from Stackoverflow that I already tried but did not work for many reasons. Plus on top of everything I want to ask for help so other people like me will be able to use DP like we used to do before to exchange information, help and teach each other.
@hdewantara I came across Irfanview but was a little skeptic about it. The site did not seem to be very popular so I didn't want to risk installing the software on my computer. Thank you very much for your help
Well, it's not for a Mac user I guess but is among the top 30... according to CNET's Most Popular Downloads for Windows. And I've been using it for years for "lightweight conversion" w/o any major problems.
Uhm... Windows Phone and most other tablets and phones (regardless of OS) should be able to view .png-files. I do not know about the Kindle, mind - I don't have one. Depending on the Kindle, it seems that image-formats are generally poorly supported on the Kindle (which is sort of natural, as it's not meant as an image-viewer).
BTW, Irfanview is one of the oldest and most reliable image-programs for the PC. Along with ACDSee and FastStone Image Viewer, they're among the best for converting, viewing and minor editing out there.
Yeah, PNG should work on anything made after 1998... if they're not 'working' there's probably something else wrong with them; like being too large for the mobile device's memory, or being improperly encoded. Could you provide a link to an example page where you are having issues? I've got the feeling that PNG is NOT your problem. (hell, even IE 4 supported PNG so long as you didn't need alpha transparency).
Just as a side-note, only changing the file extension will not make it possible for an application to decode the contents. That's like labelling a French book "Written in English" but not translating it.
Believe it or not it did work when I changed just the extension. Please check out this link for more details: http://muslimsintheus.com/Quran/pagination/index2.php?currentpage=800 Thank you
What browser? I'm not getting that center image here at all in IE, Opera or Chrome... it IS showing up in FF however which is actually WRONG -- as just renaming the file doesn't MAKE it that type of file. You actually have to convert it... ... and given most mobile browsers use either Presto (legacy Opera) or Webkit/Blink (safari, chrome, new useless crippled Opera); well there's your problem.
That's because your computer is smart enough to figure out that the extension is wrong, identify the file type by its header and use the right decoder. Which is absolutely not guaranteed to work on any other device and doesn't mean the file is a JPG - it's still a PNG and being treated as a PNG... your computer just doesn't bother to tell you.
I'm using Chrome and the image is showing on my computer. I even tried it on my friend's computer and it worked. for the mobile browser, I'm using Incognito Browser. Back to the main subject if you don't mind anyone know of a php script that can change extension in bulk. Thank you so much
THAT IS the main subject, as what you are trying to do is just going to make things WORSE, likely isn't actually what's wrong, and generally speaking, you are trying to do something you should NEVER BE DOING IN THE FIRST BLASTED PLACE -- changing the file extension but not actually changing what the file IS. Simply renaming jpg to png or vice-versa without ACTUALLY CHANGING THE FILE FORMAT is half-assed halwit BULL that to be frank, that you are even trying to do it probably means you don't know enough about files, filesystems, programming, or the web to be managing a website in the first place! Sorry if that's harsh, but that's the truth. Of course, the laugh being that if you REALLY want to do this regardless of how badly it is going to screw the pooch, this is a shell / command line tool's job, not PHP. Open up your terminal/shell/ssh session (whichever is appropriate) Windows PowerShell / command / DOS: rename *.png *.jpg BASH (*nix) rn ./*png ./*.jpg Though again, you REALLY have NO BUSINESS DOING THIS!!! (as evidenced by it NOT working here worth **** in anything but FF). If your "PNG" files aren't working, there's something wrong with them... like maybe you have jpegs that are labelled png? Have you already screwed around with the wrong extensions so badly that you have a inconsistent mess?
Actually, it doesn't work. If I click "show image" and then "save image", it downloads as a png-file. Which it should, since that's what it is. Chrome browser on Android