Batch cronjob image processing in php

I need to import images from a third-party source. the import file looks like this:

// import.csv group1;nameofimage1;http://www.site.com/image/image1.jpg;nameofimage2;http://www.site.com/image/image2.jpg; etc... 

You can have up to 20 images per line.

I have a cronjob that reads a file and then processes it (loop each line, parse each line, then spin to get an image, etc. - this is im ok).

the provided image is too large for what I need, and for each file I need to resize it to 50% of their original size. I tried using the gd library, but it takes a very long time to complete.

This is normal? what can i use to make it faster?

thansk

+6
source share
1 answer

GD library is not optimized for large images .. in fact, I would not recommend using GD at all .. only if you do not have other options.

ImageMagick is your master here :)

And another little bit. It is better not to use PHP for this task. You can use the imagemagick tools command line to do this . Just add another line to your cron / bash script to automatically resize the images if necessary.

+7
source

Source: https://habr.com/ru/post/900729/


All Articles