[TYPO3-english] Resizing images from an extension

Jigal van Hemert jigal at xs4all.nl
Sun Jul 5 23:36:54 CEST 2009


Martin Bernt Rud wrote:
> I have made some kind of wall extension where users can post a message and
> attach an image file. I now want the extension to resize the image placed in
> the uploads/tx_myext-folder to maximum 400 px width. In other words I
> _don´t_ want TYPO# to create a thumbnail in the typo3temp-folder and keep
> the original file in the  uploads/tx_myext-folder. _Instead_ I want the
> extension to resize and overwrite the original file (to save space on the
> webhotel).

I would do the normal stuff to resize the file:

$path = 'uploads/tx_myext/';

$info = $this->cObj->getImgResource($path . $filename, array('maxW' => 400);

$info[3] now contains the location and filename of the resized image.

@unlink($path . $filename);
@rename($info[3], $path . $filename);
@unlink($info[3]);

I left out the normal checks to see that the file manipulation functions 
did not fail. Also make sure that the $filename does not include a path!

Because this is internal file manipulation of the extension I don't 
think that t3lib_extFileFunctions::func_move() is relevant here; there 
is no need to do normal checks for permissions, etc. of a BE user. 
Please let me know if other think that I am completely wrong here...

Regards,

-- 
Jigal van Hemert.


More information about the TYPO3-english mailing list