General Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingGeneral Programming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
  #1  
Old September 17th, 2002, 08:58 PM
elamia elamia is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 6 elamia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #2  
Old September 17th, 2002, 09:22 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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??

Reply With Quote
  #3  
Old September 18th, 2002, 09:46 AM
elamia elamia is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 6 elamia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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
Attached Images
File Type: jpg eidiseis-17-09-2002-1.jpg (19.9 KB, 337 views)

Last edited by elamia : September 18th, 2002 at 09:49 AM.

Reply With Quote
  #4  
Old September 18th, 2002, 07:05 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
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

Reply With Quote
  #5  
Old September 19th, 2002, 11:46 AM
Phynias Phynias is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 18 Phynias User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
You want to do a water mark correct if so here ya go.

PHP Code:
<?php



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($photoImagetrue);
$logoImage ImageCreateFromPNG($watermark);
$logoW ImageSX($logoImage);
$logoH ImageSY($logoImage);
ImageCopy($photoImage$logoImage$horizmargin$vertmargin00$logoW$logoH);
ImageJPEG($photoImage); // output to browser  
//uncomment next line to save the watermarked image to a directory. need write access(changed directory to anything)
//ImageJPEG($photoImage, "marked/" . $newname, $quality);

ImageDestroy($photoImage);
ImageDestroy($logoImage);
}
watermark("018.jpg","018.jpg","proof150.png",100);
?>

the above code puts the watermark dead center.
to move it to the bottom just change the ImageCOpy line to
PHP Code:
 ImageCopy($photoImage$logoImage$horizmargin$height-$logoheight00$logoW$logoH); 


Last edited by Phynias : September 19th, 2002 at 11:55 AM.

Reply With Quote
  #6  
Old September 19th, 2002, 02:15 PM
elamia elamia is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 6 elamia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #7  
Old September 19th, 2002, 02:30 PM
Phynias Phynias is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 18 Phynias User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #8  
Old September 19th, 2002, 07:19 PM
Ben Rowe
Guest
Dev Articles Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
cool, didnt know about that stuff, very interesting, ill have to try it out when i get some time

Reply With Quote
  #9  
Old September 20th, 2002, 12:23 AM
elamia elamia is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 6 elamia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
:((((

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......

Reply With Quote
  #10  
Old September 20th, 2002, 08:51 AM
Phynias Phynias is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 18 Phynias User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #11  
Old September 20th, 2002, 02:55 PM
elamia elamia is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 6 elamia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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

Reply With Quote
  #12  
Old September 20th, 2002, 03:01 PM
Phynias Phynias is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Jul 2002
Posts: 18 Phynias User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #13  
Old September 20th, 2002, 03:35 PM
FrankieShakes FrankieShakes is offline
Frank The Tank!
Dev Articles Beginner (1000 - 1499 posts)
 
Join Date: Jun 2002
Location: Toronto, Canada
Posts: 1,246 FrankieShakes User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 8
Send a message via ICQ to FrankieShakes Send a message via MSN to FrankieShakes
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

Reply With Quote
  #14  
Old September 21st, 2002, 04:04 AM
elamia elamia is offline
Junior Member
Dev Articles Newbie (0 - 499 posts)
 
Join Date: Sep 2002
Posts: 6 elamia User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingGeneral Programming Help > Image manipulation.. please advice!!!


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump