Hey all,
i have created image by mixing logo and the original image. It create image and show in the same window.
I have done 3 steps for this.
First i upload an image to my server by using move_upload_file, then i resize it using class "thumbnail.class.php"
My next step was to embed company logo in it(which i already done) and save new embedded logo image to the path where i first upload the original image i mean i want to overwrite the new created image on the previously uploaded image in my step1.
Here is my code which upload image first, resize it and then create a new embed logo image -
include("includes/thumbnail.class.php");
-
-
$file_extension=strtolower(get_ext($_FILES['photo_1']['name']));
-
$photo_1="images/cars/".time().'_1.'.$file_extension;
-
copy($_FILES['photo_1']['tmp_name'],$photo_1);
-
$imageproduct = new Thumbnail($photo_1, 640, 480, 100);
-
$imageproduct->save($photo_1);
-
-
$watermarklogo="images/logo.png";
-
$imagelogo = watermark($photo_1,$watermarklogo);
-
Here is my Watermark function code which produce the embedded logo image -
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);
-
}
-
When it produce my embed logo image, it shows me the new produce image on the same window. Please find the attached image for reference
I want to save the new produce image on the path where in first step i upload the image.
i have the path information but how can i overwrite the new produce image on the existing uploaded image.
Kindly help me out to sort out my problem.
Awaiting of reply
kind regards,
Mohsin Rafique
3 3081
there is a function "imagejpeg" in watermark function which overwrite the uploaded image but it do not work normal. it just give me a url. i am attaching picture of it.
I am giving 8 pictures upload feature at the same time. But my function only work for first image and it stops and show the url as shown in attached image.
I want that it works with every uploaded image and works with normal i mean if i will upload 8 images, it automatically upload all 8 images and refresh the page and also show the uploaded images too on that same page. But when i include that watermark function it stops me to after overwriting very first uploaded image and show the URL. i want that it works with every uploaded image and then show me the uploaded image at the same page.
Awaiting of reply
I have done that myself.
Hurrayyyyyyyyyyyy
I just need to exclude header from watermark script. It was all i have to do is. Now my script is working fine.
Atli 5,058
Expert 4TB
Hi.
Glad you solved the problem!
And thanks for sharing the solution. Might be useful for somebody else facing the same problem.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Tim T |
last post by:
Hi,
Could someone please point to to a tutorial / code for dynamically resizing
images on upload, THEN saving to disk on the webserver.
I need users to be able to upload images to my server, but...
|
by: Ben Becker |
last post by:
Why when I open an image in VB.NET, display it in an image box, then call
the image.save property to save it to a file as a different format (e.g.
tiff image with save to jpeg) does it become 10...
|
by: garethrichardadams |
last post by:
Hello all,
I've got a user control I've created called canvas. Doesn't do much at
the moment.
I've set the background image to a small bitmap using BackgroundImage
and I've set it to tiled...
|
by: Hrvoje Vrbanc |
last post by:
I would like to know the most efficient way to copy an image from an
Internet URL to the local hard disk by means of using an ASP.NET page.
So, I would like to click the button on the ASP.NET...
|
by: Dale |
last post by:
I am creating GIF images with transparent backgrounds on-the-fly for a web
app and rendering them by using
System.Drawing.Image.Save(Response.OutputStream, ImageType.GIF).
I am confident that...
|
by: SveinErik |
last post by:
Hi, I'm trying to find a method to save bmp, jpg and png files as ico
files, 16x16 size. I have managed to convert and save bmp files to
icon, but only in 32x32 size. I can't figure out how to save...
|
by: Joe |
last post by:
does anyone know why this source code throws an error??
Dim myBitmap As System.Drawing.Bitmap
Dim myGraphics As Graphics
myBitmap = New System.Drawing.Bitmap(fileName:="C:\test.tif")...
|
by: Logician |
last post by:
I am running on my PC Windows Forms to collect data from websites,
including images.
I hit a problem with images and javascript, and I would appreciate any
help.
The current code fails with a...
|
by: admiralato |
last post by:
Hi guys,
I need to insert an image to an email. The IMAGE.SRC of the image is from a file named, Graphics.aspx.
What I'm thinking is in order for me to include the generated image in the email,...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
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: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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?
| |