DaveLinger Posted July 12, 2006 Share Posted July 12, 2006 Here's what I'm hoping for... a page on which the user can upload an image via a web form. PHP then resizes that image to like 1024x1024, watermarks it with text, saves it, resizes it to like 120x120, then saves the thumbnail. (with the watermark saved on the original one resized as well)here are the "chunks" I have... just dont know how to put it all together...WEB FORM[code]<form enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post"><input type="hidden" name="MAX_FILE_SIZE" value="3072000"><input name="userfile" type="file" /><input type="submit" value="Upload" /></form>[/code]UPLOAD[code]if (@is_uploaded_file($_FILES["userfile"]["tmp_name"])) {copy($_FILES["userfile"]["tmp_name"], "files/" . $_FILES["userfile"]["name"]);[/code]RESIZE[code]function Resize_Image($save,$file,$t_w,$t_h,$s_path,$o_path) { $s_path = trim($s_path); $o_path = trim($o_path); $save = $s_path . $save; $file = $o_path . $file; $ext = strtolower(end(explode('.',$save))); list($width, $height) = getimagesize($file) ; if(($width>$t_w) OR ($height>$t_h)) { $r1 = $t_w/$width; $r2 = $t_h/$height; if($r1<$r2) { $size = $t_w/$width; }else{ $size = $t_h/$height; } }else{ $size=1; } $modwidth = $width * $size; $modheight = $height * $size; $tn = imagecreatetruecolor($modwidth, $modheight) ; switch ($ext) { case 'jpg': case 'jpeg': $image = imagecreatefromjpeg($file) ; break; case 'gif': $image = imagecreatefromgif($file) ; break; case 'png': $image = imagecreatefrompng($file) ; break; } imagecopyresampled($tn, $image, 0, 0, 0, 0, $modwidth, $modheight, $width, $height) ; imagejpeg($tn, $save, 100) ; return;}$save = 'myfile.jpg';$file = 'original.jpg';$t_w = 120;$t_h = 120;$o_path = " ";$s_path = " ";Resize_Image($save,$file,$t_w,$t_h,$s_path,$o_path);[/code]WATERMARK[code]$white = imagecolorallocate($image, 255, 255, 255);$text = 'MyText';$font = 'CALIBRI.TTF';imagettftext($image, 10, 0, 10, 10, $white, $font, $text);imagejpeg($image, $save, 100);[/code]any ideas on how to put it all together? Quote Link to comment https://forums.phpfreaks.com/topic/14394-complicated-image-script-help/ Share on other sites More sharing options...
Barand Posted July 12, 2006 Share Posted July 12, 2006 Perhaps I can refer you to this posthttp://www.phpfreaks.com/forums/index.php/topic,99470.msg393481.html#msg393481which was my reply to this exact same question last time you posted it.Please read the forum guidelines and do not double post. Quote Link to comment https://forums.phpfreaks.com/topic/14394-complicated-image-script-help/#findComment-56907 Share on other sites More sharing options...
DaveLinger Posted July 12, 2006 Author Share Posted July 12, 2006 Actually the question is not the same. Originally I had not asked for the original image to be resized before it was saved, which throws it all off. Quote Link to comment https://forums.phpfreaks.com/topic/14394-complicated-image-script-help/#findComment-56946 Share on other sites More sharing options...
litebearer Posted July 13, 2006 Share Posted July 13, 2006 Just a thought (or two)....(1) consider the real objective - presumably to prevent unauthorized use of an image.(2) realizing that your example ( 1024 x 1024 original to 120 x 120 thumb), is exactly that - an example, IF we were to create an image 1024 x 1024, it would take a watermark approximately 400 x 400 to have the mark be of sufficient size to 'protect' the image AND to still be visible when scaled down to 120 x 120. (3) re-evaluate the need for the thumb to be watermarked, it will have lost sufficient definition during the resizing process so as to make it unsuitable for enlarging.(4) re-evaluate the need for watermarking at all. If I so desperately wanted to 'steal' an image, it would take well under an hour to remove all traces of a watermark using readily available graphics software.(5) consider who might attempt to 'steal' your images. one must remember laws protect all of us, and it is very easy to obtain a judgment against someone who has infringed upon our rights and property. HOWEVER, collecting on that judgement is extremely difficult and time consuming. Not to mention that although a court may agree that you have been 'injured'; the value of that 'injury' may be miniscule in the court's eyes.Just an old man's two cents.Lite... Quote Link to comment https://forums.phpfreaks.com/topic/14394-complicated-image-script-help/#findComment-57045 Share on other sites More sharing options...
DaveLinger Posted July 13, 2006 Author Share Posted July 13, 2006 lite,thanks, but the watermarking isn't really to prevent malicious graphics swindlers from using my images, more to inform people of where the image was loaded from, if people link to my images from their site. I couldn't care less if they SAVE it and alter it, its not using MY bandwidth.should I resize it to 120x120 BEFORE I watermark it then watermark each one individually(maybe in tinyfont for the thumb) rather than resizing the already watermarked 1024?Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/14394-complicated-image-script-help/#findComment-57057 Share on other sites More sharing options...
litebearer Posted July 13, 2006 Share Posted July 13, 2006 I would think that watermarking the thumbnail AFTER it is created would provide the best clarity of the watermark message. Text has a tendency to become very blurred when it is reduced AFTER it is created. (O's e's, a's, g's and r's end up with the 'loop' closing into a dot).Lite... Quote Link to comment https://forums.phpfreaks.com/topic/14394-complicated-image-script-help/#findComment-57062 Share on other sites More sharing options...
DaveLinger Posted July 13, 2006 Author Share Posted July 13, 2006 alright :)so... Quote Link to comment https://forums.phpfreaks.com/topic/14394-complicated-image-script-help/#findComment-57064 Share on other sites More sharing options...
DaveLinger Posted July 13, 2006 Author Share Posted July 13, 2006 bizzump Quote Link to comment https://forums.phpfreaks.com/topic/14394-complicated-image-script-help/#findComment-57269 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.