[Typo3-dev] use IM combine funtion in an extension

Wengrzik, Andreas Wengrzik at ewr.de
Tue Feb 22 15:52:03 CET 2005


hi zach!

This gallery looks great!
Its fast too. So will it be released in the repository or is it a work for a client of you without permission to publish?
And is it also still under development or finished yet?

I´m still using lz_gallery but with some hardcoded changes :/ so it is now very slow...

But thanks for your function i will try it!!


> -----Original Message-----
> From: Zach Davis [mailto:zach at castironcoding.com]
> Sent: Tuesday, February 22, 2005 3:37 PM
> To: typo3-dev at lists.netfielders.de
> Subject: Re: [Typo3-dev] use IM combine funtion in an extension
> 
> 
> I recently made a gallery extension, and I spent a lot of 
> time trying to 
> use gifbuilder to create a watermark. In the end, I decided 
> not to do it 
> with gifbuilder -- first, it didn't make sense to create gifs (256 
> colors max) for photos in an image gallery. Second, it was slow and 
> difficult to work with.
> 
> In the end, we decided to modify a function we found at 
> http://www.phpgeek.com/articles.php?content_id=6 and add some caching 
> (which, as far as we were concerned, was the big plus of 
> using gifbuilder).
> 
> I'll include the function we used, for what it's worth, below. This 
> approach also allowed the gallery to determine whether the watermark 
> should be place horizontally or vertically, depending on the 
> size of the 
> image.
> 
> 	function watermark($srcfilename, $newname, $watermarks, 
> $quality) {
> 		$imageInfo = getimagesize($srcfilename);
> 		$width = $imageInfo[0];
> 		$height = $imageInfo[1];
> 		
> 		// find a watermark that fits the image, first 
> try horizontal, then 
> vertical
> 
> 		$logoinfo = getimagesize($watermarks[0]);
> 		$logowidth = $logoinfo[0];
> 		$logoheight = $logoinfo[1];
> 		$watermarkKey = 0;
> 		
> 		if($logowidth > $width) {
> 			$logoinfo = getimagesize($watermarks[1]);
> 			$logowidth = $logoinfo[0];
> 			$logoheight = $logoinfo[1];
> 			$watermarkKey = 1;
> 		}
> 
> 		$horizextra =$width - $logowidth;
> 		$vertextra =$height - $logoheight;
> 		$horizmargin =  round($horizextra / 2);
> 		$vertmargin =  round($vertextra / 2);
> 		$photoImage = ImageCreateFromJPEG($srcfilename);
> 		ImageAlphaBlending($photoImage, true);
> 		$logoImage = 
> ImageCreateFromPNG($watermarks[$watermarkKey]);
> 		$logoW = ImageSX($logoImage);
> 		$logoH = ImageSY($logoImage);
> 		ImageCopy($photoImage, $logoImage, 
> $horizmargin, $vertmargin, 0, 0, 
> $logoW, $logoH);
> 		ImageJPEG($photoImage,$newname, $quality);
> 		ImageDestroy($photoImage);
> 		ImageDestroy($logoImage);
> }
> 
> 
> To see it in action, check out:
> http://ostudio.com/index.php?id=7&no_cache=1&view=single&cat_u
id=0&sub_cat_uid=3&image_uid=354

best,
Zach



Wengrzik, Andreas wrote:
> Hello!
> 
> I try to use the combin function in a gallery extension... but with the image .params options i can
> only use the 
> 
> $this->imgconf['file.']['params'] = '-gravity SouthEast -font Tahoma -pointsize 11 -draw "fill black  text  1,1  \'myText\' text  0,0  \'myText\' fill white  text -1,-1 \'myText\'"';
> 
> 
> this looks a little big like an watermark, but i need to combine two image to get an transparent watermark - that will look much better than only text in an image.
> I also want to use an image not only text...
> 
> Any suggestions how to get it work??
> Anyone done this before?
> 
> Thanks a lot!!
> 
> bye
> 
> -andreas
_______________________________________________
Typo3-dev mailing list
Typo3-dev at lists.netfielders.de
http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev




More information about the TYPO3-dev mailing list