Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

batch image processing cronjob in php

Tags:

import

php

image

i need to import images from a third party source. the import file looks like:

// 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 the file and then process it (loop each line, parse each line then curl to get the image etc.. - that im ok).

the image provided are way too big for what i need and for each file i need to resize them to 50% of their original size. i tried to use the gd library but it takes a very long time to complete.

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

thansk

like image 892
Ken Avatar asked Nov 03 '11 19:11

Ken


1 Answers

GD library is not optimized for big images.. actually I'd NOT recommend to use GD at all.. only if you don't have other options..

ImageMagick is your wizard here :)

And other small bit. Better is to not use PHP for this task. You can use command line imagemagick tools for this. Just add another line to your cron/bash script to automatically resize images if needed.

like image 92
Vitaly Dyatlov Avatar answered Sep 24 '22 18:09

Vitaly Dyatlov