Update file.php
Update file.php

When rescanning images the first thing that happens is whether the setting to constraint image sizes is enabled. Normally this setting applies on upload but if it was set after some images were already uploaded, it didn't apply to those images. Hence the check on rescan.

The problem is, if constraints are enabled, the system doesn't check whether the image is already within constraints. It goes through the whole process of creating a new version and going through imagine which will eventually figure out the image doesn't need processing.

This modification checks the size of the image BEFORE doing all this so if it is already within constraint, we don't waste time.

I did a quick microtime() measuring on 6 images and, doing it this way, it gets between 3x to 5x faster processing one image and its thumbnails.
haeflimi/concrete5,olsgreen/concrete5,a3020/concrete5,triplei/concrete5-8,deek87/concrete5,MrKarlDilkington/concrete5,triplei/concrete5-8,haeflimi/concrete5,mainio/concrete5,concrete5/concrete5,a3020/concrete5,mlocati/concrete5,biplobice/concrete5,mlocati/concrete5,olsgreen/concrete5,deek87/concrete5,MrKarlDilkington/concrete5,jaromirdalecky/concrete5,concrete5/concrete5,biplobice/concrete5,haeflimi/concrete5,hissy/concrete5,triplei/concrete5-8,hissy/concrete5,deek87/concrete5,jaromirdalecky/concrete5,mainio/concrete5,jaromirdalecky/concrete5,rikzuiderlicht/concrete5,olsgreen/concrete5,biplobice/concrete5,rikzuiderlicht/concrete5,rikzuiderlicht/concrete5,haeflimi/concrete5,mainio/concrete5,mlocati/concrete5,deek87/concrete5,concrete5/concrete5,mlocati/concrete5,biplobice/concrete5,hissy/concrete5,MrKarlDilkington/concrete5,hissy/concrete5,jaromirdalecky/concrete5,concrete5/concrete5