Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2004-08-25 15:03:08

nednieuws
Member
From: The Home of Heineken
Registered: 2004-08-21
Posts: 14

Plug-in to automatically watermark uploaded images.

Is such a beast available or does someone have a clue on how to do this?


Regards, Charles.

Offline

#2 2004-08-25 18:12:46

kennethlove666
Member
From: arkansas
Registered: 2004-04-27
Posts: 107
Website

Re: Plug-in to automatically watermark uploaded images.

I do believe it can be done using the GD library, or if not, ImageMagick. You might look into severely modding the automatic thumbnail plugin, but it’s beyond my ability to help. I was never any good at GD/ImageMagick.


Listen to Kenneth

Offline

#3 2004-08-25 18:33:39

tmacwrig
Archived Plugin Author
Registered: 2004-03-06
Posts: 204
Website

Re: Plug-in to automatically watermark uploaded images.

this is a function I used to use for my old forum.

<pre>
function mergePix($sourcefile,$insertfile, $pos=0,$transition=50)
{

//Get the resource id´s of the pictures $insertfile_id = imageCreateFromPNG($insertfile); $sourcefile_id = imageCreateFromJPEG($sourcefile); //Get the sizes of both pix $sourcefile_width=imageSX($sourcefile_id); $sourcefile_height=imageSY($sourcefile_id); $insertfile_width=imageSX($insertfile_id); $insertfile_height=imageSY($insertfile_id); //middle if( $pos == 0 ) { $dest_x = ( $sourcefile_width / 2 ) – ( $insertfile_width / 2 ); $dest_y = ( $sourcefile_height / 2 ) – ( $insertfile_height / 2 ); } //top left if( $pos == 1 ) { $dest_x = 0; $dest_y = 0; } //top right if( $pos == 2 ) { $dest_x = $sourcefile_width – $insertfile_width; $dest_y = 0; } //bottom right if( $pos == 3 ) { $dest_x = $sourcefile_width – $insertfile_width – 5; $dest_y = $sourcefile_height – $insertfile_height – 5; } //bottom left if( $pos == 4 ) { $dest_x = 0; $dest_y = $sourcefile_height – $insertfile_height; } //top middle if( $pos == 5 ) { $dest_x = ( ( $sourcefile_width – $insertfile_width ) / 2 ); $dest_y = 0; } //middle right if( $pos == 6 ) { $dest_x = $sourcefile_width – $insertfile_width; $dest_y = ( $sourcefile_height / 2 ) – ( $insertfile_height / 2 ); } //bottom middle if( $pos == 7 ) { $dest_x = ( ( $sourcefile_width – $insertfile_width ) / 2 ); $dest_y = $sourcefile_height – $insertfile_height; } //middle left if( $pos == 8 ) { $dest_x = 0; $dest_y = ( $sourcefile_height / 2 ) – ( $insertfile_height / 2 ); } //The main thing : merge the two pix imageCopyMerge($sourcefile_id, $insertfile_id,$dest_x,$dest_y,0,0,$insertfile_width,$insertfile_height,$transition); //Create a jpeg out of the modified picture // imagejpeg ($sourcefile_id,”$targetfile”); Imagejpeg($sourcefile_id,’‘,100); ImageDestroy($sourcefile_id);

}
</pre>

Offline

#4 2004-08-25 22:33:17

nednieuws
Member
From: The Home of Heineken
Registered: 2004-08-21
Posts: 14

Re: Plug-in to automatically watermark uploaded images.

There you go, Kenneth ;)

Or, is there a place where there’s documentation about how to write a plug-in in hand-holding mode?

Tom, many, many thanks! As this doesn’t use the ImageMagick library, can you say something about the quality? I read everywhere that wrt resizing (ie. thumbnailing) ImageMagick gives much better results than NetPBM or PHP’s built-in lib. Don’t know if this “wisdom” applies to merging of pictures, though …

Last edited by nednieuws (2004-08-25 22:43:35)


Regards, Charles.

Offline

#5 2004-08-25 22:55:26

greenrift
Archived Plugin Author
Registered: 2004-03-08
Posts: 186
Website

Re: Plug-in to automatically watermark uploaded images.

> nednieuws wrote:

> There you go, Kenneth ;)

> Or, is there a place where there’s documentation about how to write a > plug-in in hand-holding mode?

> Tom, many, many thanks! As this doesn’t use the ImageMagick
> library, can you say something about the quality? I read everywhere
> that wrt resizing (ie. thumbnailing) ImageMagick gives much better
> results than NetPBM or PHP’s built-in lib. Don’t know if this “wisdom”
> applies to merging of pictures, though …

When using a lossy format (JPEG is the most likely one), you’ll have to reencode the file, so you will lose information. When using the GD you’ll have to put with the bad JPEG encoding stuff.

This reminds me to release a new version of my automatic thumbnail’s, once I do that it will be pretty easy for others to add on features.

Offline

#6 2004-08-31 08:48:34

nednieuws
Member
From: The Home of Heineken
Registered: 2004-08-21
Posts: 14

Re: Plug-in to automatically watermark uploaded images.

Sophia: Well, you don’t. Want I want to use it for is to automatically watermark images that users upload. But this has two problems:

  1. You need to have a plugin like the poll (voting) plugin, which seems hard to do (the creator of that plugin said that it is “extensive”).
  2. If it needs to be integrated with the admin interface enabling only people with privileges to do so it seems impossible as TXP doesn’t allow for admin plugins yet.

However, I’ve started a thread in the Feature Request forum which could use more votes :).

Last edited by nednieuws (2004-08-31 08:49:17)


Regards, Charles.

Offline

#7 2004-08-31 18:23:56

kennethlove666
Member
From: arkansas
Registered: 2004-04-27
Posts: 107
Website

Re: Plug-in to automatically watermark uploaded images.

you should be able to modify the automatic thumbnails plugin/hack to use this auto-watermark code.


Listen to Kenneth

Offline

Board footer

Powered by FluxBB