Hi
i have image script , and images have my own watermark on the bottom , size of this watermark 15 pixel ,,, i just need help in the code below to tell php to ignore reading this watermark while creating thumbnails for the images , i just want the watermark disappear in thumbnails only
8 1602 kovik 1,044
Recognized Expert Top Contributor
I don't think anyone will try to wade through your code in order to help you *fix* it. If they do, kudos to them. Unless you have an actual error, then I'm going to ignore the code.
Basically, the process you want to follow is this: - Make the main GD image and save it into a variable (main)
- Duplicate the GD image and save that into another variable (thumbnail)
- Add the watermark to the first GD image (main)
- Resize the second GD image to the desired thumbnail size (thumbnail)
- Save both images to the disk
Thanks for replay dear kovik
but i don't need to watermark images through script
my images already watermarked with desktop software
all i need that to tell php ignore 15 pixel from height bottom while creating thumbnail , because i don't want the watermark appear in thumbnails images , i think i need something like $crop = 15 pixel
and minus it from height i don't know how to do it exactly
kovik 1,044
Recognized Expert Top Contributor
Oh, you want to crop it? Use imagecopyresampled() and utilize the src_h parameter to tell PHP what part of the image to copy.
here is an example for image and watermark http://img683.imageshack.us/img683/2827/example.gif
but how can we set imagecopyresampled()
in this script to work together
here is code that show how thumbnail work in my script -
#create thumb
-
$thumb = gd_fit($image,$settings['thumbxy']);
-
-
#save thmb first
-
imagejpeg($thumb,"$th/$id.jpg",$settings['thumbuality']);
-
imagedestroy($thumb);
-
#then save actual jpeg
-
imagejpeg($image,"$im/$id.jpg",$settings['quality']);
-
imagedestroy($image);
-
-
$iptc = new iptc("$im/$id.jpg");
-
if($cimg[0] == 1) {
-
#it is gif keep in data
-
write_file("$im/$id.jpg",load_file("$th/$id.jpg"));
-
write_file("$im/$id.gif",$cimg[1]);
-
$iptc->set(DPI_GIF,"GIF");
-
}
-
-
function gd_fit(&$image, $target) {
-
-
//takes the larger size of the width and height and applies the
-
//formula accordingly...this is so this script will work
-
//dynamically with any size image
-
-
$width = gd_width($image);
-
$height = gd_height($image);
-
-
if ($width > $height) {
-
$percentage = ($target / $width);
-
} else {
-
$percentage = ($target / $height);
-
}
-
-
//gets the new value and applies the percentage, then rounds the value
-
$width = round($width * $percentage);
-
$height = round($height * $percentage);
-
-
//returns the new sizes in html image tag format...this is so you
-
//can plug this function inside an image tag and just get the
-
-
return gd_resize($image,$width,$height);
-
}
-
function gd_width(&$image) {
-
return imagesx($image);
-
}
-
function gd_height(&$image) {
-
return imagesy($image);
-
}
-
-
function gd_imagewidth($fname) {
-
list($width, $height) = getimagesize($fname);
-
return $width;
-
}
-
function gd_imageheight($fname) {
-
list($width, $height) = getimagesize($fname);
-
return $height;
-
}
-
-
-
-
function gd_resize(&$image,$w,$h) {
-
$ret=@imagecreatetruecolor($w, $h);
-
@imagecopyresampled ($ret,$image, 0, 0, 0, 0, $w, $h, imagesx($image), imagesy($image));
-
-
return $ret;
-
}
-
-
kovik 1,044
Recognized Expert Top Contributor - Use an imagecreatefrom* function (i.e. imagecreatefromjpeg()) to build the GD image resource from a file
- Use imagesx() and imagesy() to get the width and height of the GD image resource, respectively.
- Use the width, height, and imagecreatetruecolor() to build a canvas for a new image that is the desired size using the original width and height
- Use imagecopyresampled() to copy the desired contents of the first GD image resource (as the source) to the second GD image resource (as the destination).
- Use an image* function (i.e. imagejpeg()) to save the file.
i think we're close to solve it , i will follow your steps by it's number with my codes step 1- - function gd_loadimage($fname) { //ignore ext e.g. for xbm and xpm load jpg
-
$arr = explode(".",$fname);
-
$ext = strtolower($arr[count($arr)-1]);
-
$func = 'imagecreatefrom';
-
switch($ext) {
-
case 'jpg' :
-
case 'jpeg':
-
case 'jpe' : $func .= 'jpeg'; break;
-
case 'png' : $func .= 'png'; break;
-
case 'gif' : $func .= 'gif'; break;
-
case 'xbm' : $func .= 'xbm'; break;
-
case 'wbmp': $func .= 'wbmp'; break;
-
-
/*case 'gif' : $func .= 'jpeg'; break;
-
case 'xbm' : $func .= 'jpeg'; break;
-
case 'xpm' : $func .= 'jpeg'; break;
-
case 'wbmp': $func .= 'wbmp'; break;
-
case 'bmp' : $func .= 'jpeg'; break;
-
case 'ico' : $func .= 'png'; break;
-
case 'cur' : $func .= 'jpeg'; break;
-
case 'ani' : $func .= 'jpeg'; break;
-
case 'txt' : $func .= 'jpeg'; break;*/
-
-
-
-
}
-
if(!function_exists($func))
-
return false;
-
-
$res = @$func($fname);;
-
if(!$res)
-
$res = @imagecreatefromjpeg($fname);
-
if(!$res) return false;
-
-
return $res;
-
-
}
-
function gd_loadimage_orig($fname) {
-
if(!file_exists($fname)) return false;
-
-
$arr = explode(".",$fname);
-
$ext = strtolower($arr[count($arr)-1]);
-
-
if($ext=='jpe' or $ext == 'jpg') $ext = 'jpeg';
-
-
$func = "imagecreatefrom$ext";
-
-
if(!function_exists($func))
-
return false;
-
-
//return $func($fname,$ext=='ico'?16:'',$ext=='ico'?32:100);
-
return $func($fname);
-
-
}
step 2- -
function gd_width(&$image) {
-
return imagesx($image);
-
}
-
function gd_height(&$image) {
-
return imagesy($image);
-
}
-
-
function gd_imagewidth($fname) {
-
list($width, $height) = getimagesize($fname);
-
return $width;
-
}
-
function gd_imageheight($fname) {
-
list($width, $height) = getimagesize($fname);
-
return $height;
-
}
-
step 3-
creating thumb is using this code - #create thumb
-
$thumb = gd_fit($image,$settings['thumbxy']);
so it's using gd_fit function , this function here - function gd_fit(&$image, $target) {
-
-
$width = gd_width($image);
-
$height = gd_height($image);
-
-
if ($width > $height) {
-
$percentage = ($target / $width);
-
} else {
-
$percentage = ($target / $height);
-
}
-
-
//gets the new value and applies the percentage, then rounds the value
-
$width = round($width * $percentage);
-
$height = round($height * $percentage);
-
-
//returns the new sizes in html image tag format...this is so you
-
//can plug this function inside an image tag
-
-
return gd_resize($image,$width,$height);
-
-
}
step 4- the return from gd_fit >> function gd_resize ,,,, and it's code -
-
function gd_resize(&$image,$w,$h) {
-
$ret=@imagecreatetruecolor($w, $h);
-
@imagecopyresampled ($ret,$image, 0, 0, 0, 0, $w, $h, imagesx($image), imagesy($image));
-
-
return $ret;
-
}
-
step 5- imagejpeg and it's code >> - function write_jpeg(&$image,$fname,$quality=100) {
-
if (function_exists("imagejpeg"))
-
return @imagejpeg($image,$fname,$quality);
-
return false;
-
}
so the step number 4 that must be edit , we're close to it , i don't know exactly how to do it
kovik 1,044
Recognized Expert Top Contributor
I told you everything that you need to know, MUCH more than I even should have told you. Write the code, debug it, find out where its going wrong, THEN ask for more help.
Thank you Mr Kovik so much
i'll try to do it
i really love this forum
Greetings and Respect
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: duikboot |
last post by:
Hi all,
I'm trying to export a view tables from a Oracle database to a Mysql
database. I create insert statements (they look alright), but it all goes
wrong when I try to execute them in Mysql,...
|
by: the_proud_family |
last post by:
HELP ME PLEASE!! my email is the_proud_family@yahoo.com
I can't get the ball to go up right side and then I need it to turn
around and keep turning until velocity=0 I have been at it for the
...
|
by: x muzuo |
last post by:
Hi guys,
I have got a prob of javascript form validation which just doesnt work
with my ASP code. Can any one help me out please.
Here is the code:
{////<<head>
<title>IIBO Submit Page</title>...
|
by: d.warnermurray |
last post by:
I am doing a project for school that involves creating help files for a html
authoring tool.
If you could help me with answers to some questions it would really help.
1. What tasks do you expect...
|
by: Craig Keightley |
last post by:
Please help, i have attached my page which worksin IE but i cannnot get the
drop down menu to fucntion in firefox. Any one have any ideas why?
Many Thanks
Craig
...
| |
by: Jason |
last post by:
Hi,
I was wondering if any could point me to an example or give me ideas on how
to dynamically create a form based on a database table? So, I would have a
table designed to tell my application...
|
by: Joner |
last post by:
Hello,
I'm having trouble with a little programme of mine where I connect to
an access database. It seems to connect fine, and disconnect fine, but
then after it won't reconnect, I get the error...
|
by: tuan_vandyk |
last post by:
Hi I desperately need help with my project. Theoretically everything
should work bu it just isn't. Please email me for a copy of the
project's source code. It was made in Turbo C++ 5. Please if...
|
by: glenn123 |
last post by:
Hi, i am just about out of time to produce a working jukebox which has to perform these functions: to play music files when a track is chosen from a list which when the user presses the change genre...
|
by: tabani |
last post by:
I wrote the program and its not giving me correct answer can any one help me with that please and specify my mistake please it will be highly appreciable...
The error arrives from option 'a' it asks...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |