|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Image manipulation.. please advice!!!
Hello there,
I would like to ask you, as if you know about image manipulation with GD better than lot of people i've asked. Is there a way to apply over an uploaded image, another image which is on the server.??? The first pic is uploaded and the second picture which is allready on the server must be applied over the first one.... No transperancy or anything else. Like a 10mm line at the bottom of the upload picture. I'm looking over for that for more than 5 days with a huge amound of hours, trying php code snippets... None can do the job... I only ask for the piece of code that puts one image over the other... it that can be done of cource... P.S. The GD version installed on the system is 1.6.2 Thnx in advance, tom |
|
#2
|
|||
|
|||
|
Ok, let me get this right, you upload an image, if an image with that name already exists, copy the original image (stored on the server) over the top of the new one??
It justs seems a bit pointless to me?? like if the image is uploaded and there is already a file with that name?? wouldnt it be easier to deny the image upload, since what you come out with in the end is the same image?? |
|
#3
|
|||
|
|||
|
First of all thnx for the reply.
sorry but my english sucks, the matter in not on the name of the image, just on layering images one over the other What i want to achive is.... Upload a photo on the server.. and after i resize it realtime... I want a second static image which is allready on the server to be printed over the uploaded one.. like a thumbnail.. I attach an example( the uploaded image is the background and the blue line with logos is the static image on the server)... please respond... Thnx in advance, tom Last edited by elamia : September 18th, 2002 at 09:49 AM. |
|
#4
|
|||
|
|||
|
hmmm, i know its possible, but i dont know how to do that yet, try looking up the image functions on php.net and see if you can find something there. Currently im still reading up about the many functions of gd, and i havent come accross layering yet
|
|
#5
|
|||
|
|||
|
You want to do a water mark correct if so here ya go.
PHP Code:
the above code puts the watermark dead center. to move it to the bottom just change the ImageCOpy line to PHP Code:
Last edited by Phynias : September 19th, 2002 at 11:55 AM. |
|
#6
|
|||
|
|||
|
wow thnxxxxx!!!!
Thnx a lot for all the answers...
The code looks that it works but.... there is an error in the source image which I cannot understand.... Also another error in imagealphablending() cause GD is 1.6.2 version... Those are the errors... Warning: imagecreatefromjpeg: '018.jpg' is not a valid JPEG file in /newsite/images/reportaz/test.php on line 19 Fatal error: imagealphablending(): requires GD 2.0 or later in /newsite/images/reportaz/test.php on line 20 Why there is a problem on the jpg image?? It's uploaded via a form.. also try uploading it via ftp.. The source jpg is made firstly with photoshop and then i save it from fireworks.. but still it seems to be invalid format when the script calls it..... why is this happening?? Any ideas??? thnx in advance ppl... with respect, tom |
|
#7
|
|||
|
|||
|
You're getting the jpeg error because you have to give it a file on your server. I was giving an example you have to replace both the 018.jpg and the proog150.png
018.jpg is the main image and proof150 is the watermark as far as the error either upgrade your gd library or try commenting out the alpha line and see how it looks. probably wont look that great. |
|
#8
|
|||
|
|||
|
cool, didnt know about that stuff, very interesting, ill have to try it out when i get some time
|
|
#9
|
|||
|
|||
|
:((((
The picture 018.jpg is uploaded on the server..... and the thumbnail too... the script calls the thumbnail but when it calls 018.jpg there is an error... while the picture is online 018.jpg
why it can't read a picture with that name which is allready on the server???? plz...plz.plz...... |
|
#10
|
|||
|
|||
|
Whats the error?
Also the way I wrote it the images where all in the same directory as the script. You can rewrite that if you want. You should definatley brush up on your basic php skills, especially if you are having trouble editing this script. |
|
#11
|
|||
|
|||
|
Thnx for all the answers...
Here is the code as it is now.. function watermark($srcfilename, $newname, $watermark, $quality) { $imageInfo = getimagesize($srcfilename); $width = $imageInfo[0]; $height = $imageInfo[1]; $logoinfo = getimagesize($watermark); $logowidth = $logoinfo[0]; $logoheight = $logoinfo[1]; $horizextra = $width - $logowidth; $vertextra = $height - $logoheight; $horizmargin = round($horizextra / 2); $vertmargin = round($vertextra / 2); $photoImage = @ImageCreateFromJPEG($srcfilename); ImageAlphaBlending($photoImage, true); $logoImage = ImageCreateFromPNG($watermark); $logoW = ImageSX($logoImage); $logoH = ImageSY($logoImage); imagecopymerge($photoImage, $logoImage, horizmargin, $height-$logoheight, 0, 0, $logoW, $logoH, 0); //ImageJPEG($photoImage); // output to browser ImageJPEG($photoImage, "thumbs/" . $newname, $quality); ImageDestroy($photoImage); ImageDestroy($logoImage); } watermark("018.jpg","019.jpg","ena_logo.png",80); ?> When I first run the script 3 errors appear... The first error had to do with a wrong ImageCreateFromJPEG command.. $photoImage = ImageCreateFromJPEG($srcfilename); I change it to $photoImage = @ImageCreateFromJPEG($srcfilename); and the error was fixed... but the two errors I wrote in my previous post still appear, the one has to do with GD version but the "not a valid JPEG file " is freaking me out..... All the files are in the same directory, the directories are chmod 777 and everything seems to be ok.... With respect, tom |
|
#12
|
|||
|
|||
|
the first 2 vars passed to the watermark scipt hould be the same. 018.jpg
also you dont have to name your images 018.jpg if you still get the error. try another jpeg image maybe there is something wrong with the one you trying to use. also comment out the alpha function this may cause all yer errors. |
|
#13
|
|||
|
|||
|
It may be the format your JPEG image is saved... Although it has a .JPG extension, it may not be a compatible format with the GD library.
As Phynias stated, try another image, or try saving it in Photoshop as a "Baseline Standard" and not progressive... Or even try the "Save for Web" option... See if that works.
__________________
____________________________________________ Developer Shed Weekly Writer | DevArticles Forum Moderator Build Your Own KlipFolio Klip With PHP FrankManno.com - Under Construction Design Interactive Group - Under Construction |
|
#14
|
|||
|
|||
|
finally...............
thnx for your precious answers....
The script worked exactly as it was and with the same images too... but on another server... It must be my hosting server settings who messes thinks around... The solution is that and a second image result is that Well as you can see at the final image the logo uses the colour template of the source image, allthought the logo is a png file with no background transperant. Is there a way on merging the colors of logo and source image in the final image?? so it appears like that?? ![]() thnx in advance... with respect, tom Last edited by elamia : September 21st, 2002 at 04:08 AM. |
![]() |
| Viewing: Dev Articles Community Forums > Programming > General Programming Help > Image manipulation.. please advice!!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|