Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

 

Register GFY Rules Calendar Mark Forums Read
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
New Webmasters ask "How-To" questions here. This is where other fucking Webmasters help.

 
Thread Tools
Old 06-02-2007, 08:17 AM   #1
Goodings Media
Confirmed User
 
Goodings Media's Avatar
 
Join Date: Apr 2007
Location: UK
Posts: 1,987
Add watermark and resize image PHP script?

Hiya,

anyone know where i can get a simple (and free) PHP script that will

Take the image that a user uplaods
Add an alpha transparency watermark
resize it to a fixed size

and then pass it back to my script to insert it into the database

Ive done a fair bit of googling on this but come up with nothing. I understand it'll need to use imagemagic.

Thanks guys
__________________
ICQ: 446-568-913 Email: liam||goodingsmedia.com msn: [email protected]
Goodings Media is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 06-02-2007, 10:54 AM   #2
bonkerz2007
Confirmed User
 
Join Date: Sep 2005
Posts: 794
http://www.phpscriptexpert.com/scrip...ermark&pid=198
bonkerz2007 is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 06-02-2007, 06:03 PM   #3
Goodings Media
Confirmed User
 
Goodings Media's Avatar
 
Join Date: Apr 2007
Location: UK
Posts: 1,987
hiya,

i need the watermark to be permanent

thanks
__________________
ICQ: 446-568-913 Email: liam||goodingsmedia.com msn: [email protected]
Goodings Media is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 06-04-2007, 12:13 AM   #4
Goodings Media
Confirmed User
 
Goodings Media's Avatar
 
Join Date: Apr 2007
Location: UK
Posts: 1,987
bump for anyone who knows a bit of imagemagick
__________________
ICQ: 446-568-913 Email: liam||goodingsmedia.com msn: [email protected]
Goodings Media is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 06-07-2007, 07:58 AM   #5
lb_vee
Confirmed User
 
Join Date: May 2004
Posts: 886
Here's the docs for the imagemagick command line tools. If had a bit more time I'd actually get into the php api to see what they have.

http://www.imagemagick.org/script/composite.php

Im pretty sure you can also use the GD libs in php to get this done.
lb_vee is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 06-07-2007, 05:10 PM   #6
ASACP Cal
Registered User
 
Join Date: Jun 2007
Location: Vancouver, BC
Posts: 6
Standalone using php

I was interested in this topic also.

This code snippet will resize an image. (Remarkable what a pain in the ass such a basic operation is.) See below the example for combining images of different sizes or writing text directly to an image.

If you want to save the image you can add a path to imagejpeg (see ca3.php.net/manual/en/function.getimagesize.php for another similar example).

<?php
$upload = $_FILES['img'];
if ($upload['type'] != 'image/jpeg') die("only jpeg files are supported not {$upload['type']}!");
$resize_pct = $_REQUEST['resize_pct'];
if ($resize_pct < 0 or $resize_pct > 100) die("bad resize value $resize_pct!");

$img = imagecreatefromjpeg($upload['tmp_name']);
if (!$img) die('error processing image');
$dims = getimagesize($upload['tmp_name']);

$newx = sprintf('%d',$dims[0] * $resize_pct / 100);
$newy = sprintf('%d',$dims[1] * $resize_pct / 100);

$newimg = imagecreatetruecolor($newx,$newy);
imagecopyresampled($newimg,$img,0,0,0,0,$newx,$new y,$dims[0],$dims[1]);

# test output
header("content-type: image/jpeg");
imagejpeg($img);
--------------------------------------------------------

If you are using the same watermark or have a watermark graphic your best bet is to combine the images together.

ca3.php.net/manual/en/function.imagecopymerge.php
Has example.

If you want to use truetype or postscript fonts (requires external libraries).

ca3.php.net/manual/en/function.imagettftext.php
ca3.php.net/manual/en/function.imagepstext.php

A more bare bones approach could use the imagechar or imagestring functions.

ca3.php.net/manual/en/function.imagechar.php
ca3.php.net/manual/en/function.imagestring.php
ASACP Cal is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 06-07-2007, 05:20 PM   #7
ASACP Cal
Registered User
 
Join Date: Jun 2007
Location: Vancouver, BC
Posts: 6
minor correction

it should read imagejpeg($newimg) at the end of the code snippet.

to write to a file remove the header("content-type: image/jpeg");
and change imagejpeg($newimg) to imagejpeg($newimg,"some/image/path");

you'd want to do any other transformations after the imagecopyresampled function.
ASACP Cal is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
Old 06-08-2007, 05:03 PM   #8
Goodings Media
Confirmed User
 
Goodings Media's Avatar
 
Join Date: Apr 2007
Location: UK
Posts: 1,987
woah dude, thanks
__________________
ICQ: 446-568-913 Email: liam||goodingsmedia.com msn: [email protected]
Goodings Media is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook
 
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks
Thread Tools



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.