Forum Moderators: coopster

Message Too Old, No Replies

Converting blobs of bmp's to jpeg's

Dreadful mysql table filled with thousands of bmp's

         

Wink

4:59 pm on Feb 24, 2009 (gmt 0)

10+ Year Member



This is my nightmare. I have a mysql table loaded to the gils with tens of thousands of bmp's. I want to extract all the bmp's from the table, name them with their corresponding ID and save them in a directory.

Once I have them saved in the directory, I could run any script of my liking to covert them to jpeg's so that part will be easy.

How can I extract these bmp's to a directory and give them a name?

Thanks,

Rob

enigma1

10:25 am on Feb 25, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you retrieve the mysql rows from the table
"select image_id, image_name, image_data from images_table"

then for each row returned you save the image data with the name that can be created from the id or name if there is one.

$handle = fopen('somepath/' . $image_name . '-' . $image_id, 'w+');
if( $handle ) {
fwrite($handle, $image_data);
fclose($handle);
}

and so the above code can be placed inside the loop of the mysql retrieval of rows.