WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I was wondering if anyone knew a way (via function, plugin, or another method) of using phpThumb to process an image on upload, and then for Wordpress to generate it's usual image sizes from both the original and the processed image?

Basically I'm using phpThumb to generate an alpha channeled version of the image, to use in some specific areas, using this (where the h & w are the measurements or the original image, which could be variable)

<img src="phpThumb/phpThumb.php?src=black.jpg&h=487&w=320&iar=1&fltr[]=mask|originalimage.jpg&f=png&hash=xxxxxx">

If I then set a bunch of custom image-sizes, for example:

add_image_size( 'normal-large', 800, 400, false );
add_image_size( 'normal-medium', 600, 300, false );
add_image_size( 'normal-small', 40, 200, false );
add_image_size( 'mask-large', 800, 400, false );
add_image_size( 'mask-medium', 600, 300, false );
add_image_size( 'mask-small', 40, 200, false );

I'd like for the three normal-x sizes to generate from the original image, as per normal, and then the three mask-x sizes to be generated, using the processed version of the image.


share|improve this question
Do you know how (if at all possible) to use phpThumb for your needs without going through HTTP? That would probably be per-requisite for smooth integration. – Rarst Jun 8 '13 at 20:24
Do you mean using it server side, without having to call phpThumb from the page itself? No, not really. I did see this article for using phpThumb for pre-processing, but not sure how to get it working for the process I want to do. (where it's not just applying the filters to the uploaded image, but instead getting the dimensions of the image, resizing the black.jpg image to match, and then using the uploaded image as the mask. jamesfishwick.com/… – Nathan Jun 9 '13 at 0:50

Have you considered using a client-side jquery plugin such as:


That way you're not generating more images than you have to.

share|improve this answer
Thanks for your suggestion @anthony-r. That looks like a mighty useful plugin, but unfortunately unsuitable for this use case. It looks like it only accepts already made masks (transparent png images with black for visible and for transparent invisible). In this case, I want to use the uploaded images as the mask themselves (so from a jpeg photo). Basically, use base & uploaded image to create this. – Nathan Jun 12 '13 at 12:12

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.