I'm importing images from another script to my script.
Both of the images names are saved in the database.
My Script
Post_ID - old_pic_name - new_pic_name - is_gif
1 - long_file_name.jpg - 1.jpg - 0
2 - long_file_name2.png - 2.png - 0
3 - long_file_name3.gif - 3.gif - 1
I have dedicated server. I've tried to make that conversion using php to import the old name from filename from the database then resize and rename it. And it was successful but had a small issue.
The original website contains more than 116000 images. PHP converting was taking about 15 minutes to convert 500 photo and sometimes ends with errors and I had to restart refresh manually.
I don't know if I can't give the script all the server resources to finish the loading faster, or there's something else.
I want to do it using SHELL. May be it will be faster and it will override php max_execution_time and memory_limit limits.
The original photos are located in /old_data/ folder.
The new folders should be like that :
/o/ contains original copy of the file named with new_post_id.image_extension
/t/ contains 3 resized versions of the (728px width) name l-new_post_id.image_extension and (500px width) new_post_id.image_extension and s-new_post_id.image_extension (300px width).
For example:
First row:
ID = 1
Old Photo dir: /old_data/long_file_name.jpg
New Photo dir: /o/1.jpg (Exact copy of the original, just renamed)
New Resized Photos: /t/1.jpg (500px max-width) & /t/l-1.jpg (728px max-width) & /t/s-1.jpg (300px max-width)
I was thinking if I could export these information into a suitable file format that can be imported using bash shell in linux and use the data to do the renaming and resizing recursively using GD and ImageMagick. But honestly, I have no clue how to do that.
I hope someone can help.
Best Regards.