Hey All,
I want to embed logo while upload an image. I mean when i upload an image, i want to embed the logo of the website in that uploaded image.
Kindly help me out to sort out my problems and as i always get a reply from this great community so i believe again i will get the solution of my problem here.
kind regards,
Mohsin Rafique
21 3647
Thank you very much
I will study n try to do that. As soon as i will do i will be back with that solution
Hey Dormilich,
I found a function from there which is exactly up to my requirement but in my case it is not working and show dirty characters after creating image.
Here is my code i am using for uploading and for watermarking -
$file_extension=strtolower(get_ext($_FILES['photo_1']['name']));
-
$photo_1="images/cars/".time().'_1.'.$file_extension;
-
move_uploaded_file($_FILES['photo_1']['tmp_name'],$photo_1);
-
$imageproduct = new Thumbnail($photo_1, 640, 480, 100);
-
$imageproduct->save($photo_1);
-
$watermarklogo="images/logo_png.png";
-
watermark($photo_1,$watermarklogo);
-
And this is the function i got from there which comes up to my requirement -
function watermark($sourcefile, $watermarkfile) {
-
#
-
# $sourcefile = Filename of the picture to be watermarked.
-
# $watermarkfile = Filename of the 24-bit PNG watermark file.
-
#
-
-
//Get the resource ids of the pictures
-
$watermarkfile_id = imagecreatefrompng($watermarkfile);
-
-
imagealphablending($watermarkfile_id, false);
-
imageSaveAlpha($watermarkfile_id, true);
-
-
$fileType = strtolower(substr($sourcefile, strlen($sourcefile)-3));
-
-
switch($fileType) {
-
case('gif'):
-
$sourcefile_id = imagecreatefromgif($sourcefile);
-
break;
-
case('png'):
-
$sourcefile_id = imagecreatefrompng($sourcefile);
-
break;
-
default:
-
$sourcefile_id = imagecreatefromjpeg($sourcefile);
-
}
-
//Get the sizes of both pix
-
$sourcefile_width=imagesx($sourcefile_id);
-
$sourcefile_height=imagesy($sourcefile_id);
-
$watermarkfile_width=imagesx($watermarkfile_id);
-
$watermarkfile_height=imagesy($watermarkfile_id);
-
-
$dest_x = ( $sourcefile_width / 2 ) - ( $watermarkfile_width / 2 );
-
$dest_y = ( $sourcefile_height / 2 ) - ( $watermarkfile_height / 2 );
-
-
// if a gif, we have to upsample it to a truecolor image
-
if($fileType == 'gif') {
-
// create an empty truecolor container
-
$tempimage = imagecreatetruecolor($sourcefile_width, $sourcefile_height);
-
// copy the 8-bit gif into the truecolor image
-
imagecopy($tempimage, $sourcefile_id, 0, 0, 0, 0, $sourcefile_width, $sourcefile_height);
-
// copy the source_id int
-
$sourcefile_id = $tempimage;
-
}
-
imagecopy($sourcefile_id, $watermarkfile_id, $dest_x, $dest_y, 0, 0, $watermarkfile_width, $watermarkfile_height);
-
//Create a jpeg out of the modified picture
-
switch($fileType) {
-
// remember we don't need gif any more, so we use only png or jpeg.
-
// See the upsaple code immediately above to see how we handle gifs
-
case('png'):
-
header("Content-type: image/png");
-
imagepng ($sourcefile_id);
-
break;
-
default:
-
header("Content-type: image/jpg");
-
imagejpeg ($sourcefile_id);
-
}
-
imagedestroy($sourcefile_id);
-
imagedestroy($watermarkfile_id);
-
}
-
kindly help me out to sort out my problem pleaseeeee
any errors, warnings, notices? have you tried with bare/sample images (without uploading) first? did you check the function return values?
Yeh it post and give warning message.
And also show dirty characters in it.
I am attaching the image of it
what does the error message say? (too small to read). the error message directly involves the "dirty characters", once you clear the error it should be ok.
EDIT: the "dirty characters" are actually your picture
expressed as string
It is saying that cannot modify header information
Warning: Cannot modify header information - headers already sent by (output started at E:\server\htdocs\themosaicdesigns\site\projects\ca rsbay\includes\thumbnail.class.php:423) in E:\server\htdocs\themosaicdesigns\site\projects\ca rsbay\edit-photos.php on line 272
what does
output started at E:\server\htdocs\themosaicdesigns\site\projects\ca rsbay\includes\thumbnail.class.php:423
refer to?
@neovantage
On line 423 of E:\server\htdocs\themosaicdesigns\site\projects\ca rsbay\includes\thumbnail.class.php, you have sent output to the browser. You cannot do that if you intend to modify the headers later.
Basically thumbnail.class.php resize my uploaded image.
What i want actually is
i want to upload pictures. Pictures may be large in size so i have to resize them as the client requirement. Now he want that When an image upload then it must be resize and also this process embed his website logo tu the uploaded image and that is what i am trying to do.
i am using thumbnail.class which resize the uploaded image and save it to the required path.
If i even exclude it even then it shows n give me dirty characters and do not embed logo into the uploaded image
So what should i do now.
As i need to upload the image, embed logo into uploaded image, then i need to resize the image and then need to save it
Sir i want that when i upload an image it get that image.
1. Upload it to the server
2. Embed logo into it
3. Resize it too.
These 3 things i want to do
Awaiting of your guideline to do these step by step
first, check what's causing the output in thumbnail.class.php on line 423.
i am attaching the file thumbnail.class.php file as in line 423 there is nothing in it
you have 2 line breaks after the closing "?>", that counts as outputremove them.
you should use "<?php" as start tag, not every system allows short tags.
@Dormilich
To prevent accidental output after the closing PHP tag, you can just omit it all together. This is a common practice, and is, I believe, enforced in the Zend Coding Standard.
But my problem is still there.
I still unable to do these 3 tasks simultaneously
1. Upload it to the server
2. Embed logo into it
3. Resize it too.
So what should i do now? i am still there from where i start
Hey Dormilich and Markus,
Hope you are best in health and life. So please guide me what should i do now so that i can upload images, embed logos and resize them simultaneously.
Awaiting of your reply
Mohsin Rafique
@neovantage
this is a long thread. i didn't see that you ever cleared this error and it might be the source of your problem. i'm guessing the offending line is trying to send the file type information to the header. you can't do this if you've already sent information to the browser (eg using the function 'echo');
there is a workaround for delaying that information from being sent immediately and still modify the header. try putting ob_start(); on the first line of your php code and ob_get_clean(); on the last line of your php code. you can also read about output buffering here: http://us2.php.net/manual/en/intro.outcontrol.php
my script is uploading picture now and also resizing them. But when i embed logo into the picture it output the embedded log picture into the same window. But how can i overwrite that new picture on the existing picture on the directory path.
Please find the attached images of the output.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: dave |
last post by:
Hello there,
I am at my wit's end ! I have used the following script succesfully to
upload an image to my web space. But what I really want to be able to do is
to update an existing record in a...
|
by: Atanas Boev |
last post by:
Is there any CSS way to make a <hr /> noshadow so I don't get the default 3D
look in Netscape?
I tried to use some border-bottom to make the line, but my "line" should be
under text that is...
|
by: deko |
last post by:
Is it possible to store a company logo (a gif file) in a table (binary
field) and have the logo appear in a form? If I insert a picture object in
the form, the properties sheet of the Image...
|
by: David Lozzi |
last post by:
Howdy,
I have a function that uploads an image and that works great. I love ..Nets built in upload, so much easier than 3rd party uploaders!
Now I am making a public function that will take the...
|
by: Michael Tobis |
last post by:
"Is this the right room for an argument?"
http://geosci.uchicago.edu/~tobis/snake.png
ok, so my execution is pretty crude, but you can at least see my idea.
I trust you to imagine it...
|
by: Manuel |
last post by:
Is it possible to embed an image, like a company logo in a CDOSYS generated
message?
If yes, IĀ“ll apreciate some code sample. IĀ“ve been able to format messages
in html the way I like, but I...
|
by: rkontham |
last post by:
Hello...
We are developing the intranet application.In that i should place our company logo in each html and asp page.And givw chance to the Client to change that logo.(they can upload their...
|
by: Amir Michail |
last post by:
Hi,
The following gradient method involves scaling a gradient image. How
would one put a logo on top of such a scaled gradient image without
also scaling the logo image?
...
|
by: raamay |
last post by:
I am trying to embed company logo (image) in an html email which i am sending using PHP mail function. I tried the following way but didnt work. So, I am not sure how to go about. Please see my code...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
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: 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...
| |