hello, i want to take an image, rotate it 15 degrees then center it in a white canvas 220 width x 120 height.
thanks
hello, i want to take an image, rotate it 15 degrees then center it in a white canvas 220 width x 120 height.
thanks
This sounds like it would be done with JavaScript, not PHP.
Edit: Seems I was wrong, sort of forgot about the GD library =/
Last edited by Schmoopy; 09-19-2009 at 12:05 AM.
You can use php for this. I do.
http://us2.php.net/manual/en/function.imagerotate.php
and
http://us2.php.net/manual/en/functio...ecopymerge.php
should do it. For the list of GD functions that php uses go to http://us2.php.net/manual/en/book.image.php . Here is an amateur tutorial that I created on the subject. http://www.animeviews.com/article.ph...ry=programming
To choose the lesser of two evils is still to choose evil. My personal site
Or PHP-GD.
I think I REALLY screwed that up, but that's the outline for you. HTHPHP Code:<?php
$filename = 'test.jpg';
header('Content-type: image/jpeg');
$source = imagecreatefromjpeg($filename);
$rotate = imagerotate($source, 15, 0);
$im = imagecreate(220, 120);
$img = imagecopy($im, $im, 0, 0, 0, 0, 0, 0);
imagejpeg($rotate);
?>![]()
- Josh
The GD library for PHP will rotate it and give you an image. Flash will let you do it on the page. Javascript won't be much help because it won't do well with non-90-degree angles (if you wanted to make an image sideways, there is probably a reasonably way in Javascript, but not 15 degrees).
Based on what you said, I think the GD library as suggested above is the right way to go.
However, it's probably better to just save these images in the first place as you want, using a PHP-GD script if you'd like, but not running it every time the page loads, because that will be slow and cause a strain on the server. If you are doing it with user uploads or something else you can't batch process before, then you could just process once with GD and save that output so you are still only running the script once.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Sounds like he has a unique image every time, so I think he'll have no choice but to run the script each time. Maybe he can make a copy of the image if the image is repeated?
- Josh
Right. If it can't be pregenerated, then caching the image is the best option.
I have a gallery script I did where it is live-- it just grabs all the images from the folder and puts them on the page (as thumbnails generated by GD, with links to the actual files), but it does so by looking through all the images in the folder and generating the thumbnail only if the thumbnail is not already saved in a folder. I save the thumbnail based on the md5 value of the image itself, so that is an easy way to be sure the image hasn't been updated. The only downside to that is leaving extra thumbnails in the cached folder once an image is deleted, but it doesn't really cause much of a problem.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
thanks guys,
i'm just having a play with a few of the scripts..
If you look at the images i've attached, you can clearly see what im after..
thanks for your help
In addition to the image you want, exactly, you need to also decide how you want it to work-- process the image every time the page loads, preprocess everything, do it only if it isn't already generated, etc. For this, the reasons behind the script are most important-- is it part of your layout, for products on a page, for user uploaded photos, etc.
Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum
Bookmarks