|
| ||||||||||
| Tags: images, modify, php |
![]() |
| | Thread Tools | Search this Thread |
|
#1
| |||
| |||
| How to modify an existing images in PHP
I want to ask you'll about the code in PHP that will help me to modify the exising images. Can anybody provide me the PHP code to do the same ? thanks... |
|
#2
| ||||
| ||||
| Re: How to modify an existing images in PHP Modifying an Existing Image in PHP To use an existing GIF, JPEG or PNG image as a canvas on which you add additional elements, use one of the following functions instead of imagecreate(). imagecreatefromgif ( string $filename ) imagecreatefromjpeg ( string $filename ) imagecreatefrompng ( string $filename ) For example, if you created a GIF file called "mytemplate.gif", the function can be called as follows: $myimage = imagecreatefromgif ( "mytemplate.gif" ); |
|
#3
| ||||
| ||||
| Re: How to modify an existing images in PHP
Modifying a image is very similar to the form to add the image except for the image thumbnail. Clicking on the thumbnail will call the javascript function viewLargeImage() which will open a popup displaying the full-sized image. If you checkout the form code you can see that we use htmlspecialchars() function when printing the image description in the textarea. After you click the "Modify Image" button we continue saving the new information and also save the new image ( if a new one is provided ). The process is just a repetition of the code to modify album data and image. The difference is that now we modify two images, the full-sized image and the thumbnail. Code: <!-- google_ad_section_start(weight=ignore) -->
// ... some code here
if (isset($_POST['txtTitle'])) {
$albumId = $_POST['cboAlbum'];
$imgTitle = $_POST['txtTitle'];
$imgDesc = $_POST['mtxDesc'];
if ($_FILES['fleImage']['tmp_name'] != '') {
$images = uploadImage('fleImage', GALLERY_IMG_DIR);
if ($images['image'] == '' && $images['thumbnail'] == '') {
echo "Error uploading file";
exit;
}
$image = "'" . $images['image'] . "'";
$thumbnail = "'" . $images['thumbnail'] . "'";
$sql = "SELECT im_image, im_thumbnail
FROM tbl_image
WHERE im_id = $imgId";
$result = mysql_query($sql)
or die('Error, get image info failed. ' .
mysql_error());
$row = mysql_fetch_assoc($result);
unlink(GALLERY_IMG_DIR . $row['im_image']);
unlink(GALLERY_IMG_DIR . 'thumbnail/' . $row['im_thumbnail']);
} else {
// the old image is not replaced
$image = "im_image";
$thumbnail = "im_thumbnail";
}
if (!get_magic_quotes_gpc()) {
$albumName = addslashes($albumName);
$albumDesc = addslashes($albumDesc);
}
$sql = "UPDATE tbl_image
SET im_album_id = $albumId,
im_title = '$imgTitle',
im_description = '$imgDesc',
im_image = $image,
im_thumbnail = $thumbnail,
im_date = NOW()
WHERE im_id = $imgId";
mysql_query($sql) or die('Error, update image failed : ' .
mysql_error());
echo "<script>window.location.href = 'index.php?page=image-detail&imgId=$imgId';</script>";
}
// ... more code here
<!-- google_ad_section_end --> |
|
#4
| ||||
| ||||
| Re: How to modify an existing images in PHP
If you want modify the contrast and colours of the image in php - Here are some of the examples (the jpeg image of house is considered as instance) ----------------------------------------------------------------- <?php exec("convert House.jpg -fill black -colorize 15% colorize.png"); ?> ----------------------------------------------------------------- <?php exec("convert House.jpg -contrast-stretch 2% stretch.png"); ?> ----------------------------------------------------------------- <?php exec("convert House.jpg -level 5%,95%,0.8 level.png"); ?> ----------------------------------------------------------------- <?php exec("convert House.jpg -normalize normalize.png"); ?> ----------------------------------------------------------------- <?php exec("convert House.jpg -sigmoidal-contrast 3,75% sigmoidal.png"); ?> ----------------------------------------------------------------- |
![]() |
|
| Thread Tools | Search this Thread |
| |
Similar Threads for: "How to modify an existing images in PHP" | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to add images to Google Images | Monty1 | Tips & Tweaks | 2 | 14-02-2011 12:15 PM |
| Want to have Moblin on existing Ubuntu | Bindoo | Portable Devices | 4 | 16-11-2010 03:03 PM |
| Unable to modify the databse with the same name as an existing database | Reckon | Software Development | 3 | 08-08-2009 10:48 AM |
| How 3G different from existing services ? | RohanS | India BroadBand | 3 | 04-03-2009 11:57 AM |
| Add 2 GB of ram to my existing 2 GB | Silent~Kid | Motherboard Processor & RAM | 5 | 27-02-2009 09:15 AM |