Solved

using php want to add whitespace to bottom of image

Posted on 2010-08-12
4
391 Views
Last Modified: 2012-05-10
current image is 300x300

add
100 pixel width
100 height

whitespace to an image

I want the whitespace to be at the bottom right of the image
0
Comment
Question by:rgb192
  • 2
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
pironic earned 500 total points
ID: 33421235
here is the working code for this... i've used imagecreatefrompng, but you can use imagecreatefromgif or jpeg if you want too.
<?php 

header('content-type: image/jpeg');  

$orig = imagecreatefrompng("http://".$_GET['src']);  
$orig_width = imagesx($orig);  
$orig_height = imagesy($orig);  
$image = imagecreatetruecolor($orig_width+100, $orig_height+100);  
$white = imagecolorallocate($image, 255, 255, 255);
imagefill($image, 0, 0, $white);
imagecopymerge($image, $orig, 0, 0, 0, 0, $orig_width, $orig_height, 100);  
imagejpeg($image);  
imagedestroy($image);  
imagedestroy($orig);  

?>

Open in new window

0
 
LVL 2

Expert Comment

by:pironic
ID: 33421282
0
 

Author Comment

by:rgb192
ID: 33432393
does not save the new image
0
 

Author Closing Comment

by:rgb192
ID: 33432508
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now