gd

PHP - Replace colour within image

☆樱花仙子☆ 提交于 2019-11-27 08:58:35
I hope someone can help, I have made a script that masks images... however it is reliant on a colour to mask with ( 'green screen' style). The trouble is if the image that I am masking contains that colour it is ruined. What I am looking to do is prior to masking the image replace any occurance of my keying colour (0,0,255) with a similar colour such as 0,0,254. I have found a few solutions based around gif's or 256 colour PNG as they are indexed.. So my question is also will it be more efficient to convert it to a gif or 256 png then look through the index and replace the colour or search

Convert tiff to jpg in php?

让人想犯罪 __ 提交于 2019-11-27 08:56:11
I have a server which holds TIFF images. Most clients can read and display TIFF images, so there's no problem. However, some clients can't handle this format but can handle JPG. I thought of using PHP's GD library to do a server side conversion for clients without TIFF reading abilities. But I noticed GD can't read TIFF files too. Imagick not working in windows, My idea was to create an imageFetcher.php which gets as a parameter the actual image the client wants. It checks the client's type and if needed converts the image and outputs a JPG, otherwise it simply outputs the TIFF. does anyone

Perl GD module won't install -

杀马特。学长 韩版系。学妹 提交于 2019-11-27 07:56:15
问题 I'm trying to figure out why I can't get the GD perl module to install on my Debian 7 server. Here is how I installed the core stuff: sudo apt-get install libgd-gd2-perl Then running the -MCPAN to install, I get: root@myserver:~# sudo perl -MCPAN -e 'install GD' Going to read '/root/.cpan/Metadata' Database was generated on Sun, 19 Jul 2015 21:41:02 GMT Running install for module 'GD' Running make for L/LD/LDS/GD-2.56.tar.gz Checksum for /root/.cpan/sources/authors/id/L/LD/LDS/GD-2.56.tar.gz

PHP/GD : Better Gaussian blur

纵然是瞬间 提交于 2019-11-27 07:53:20
I want to blur an image with GD library, unfortunately the GAUSSIAN_BLUR effect that GD gives isn't enough and i want something being more blurrish <?php $im = imagecreatefrompng($_GET['image']); if($im && imagefilter($im, IMG_FILTER_GAUSSIAN_BLUR)) { header('Content-Type: image/png'); imagepng($im); } else { echo 'fail'; } imagedestroy($im); I want something like this or at least near it. JKirchartz You can try convolution: $gaussian = array(array(1.0, 2.0, 1.0), array(2.0, 4.0, 2.0), array(1.0, 2.0, 1.0)); imageconvolution($image, $gaussian, 16, 0); $gaussian is a matrix, so mathematically

Creating an image without storing it as a local file

我只是一个虾纸丫 提交于 2019-11-27 07:41:41
Here's my situation - I want to create a resized jpeg image from a user uploaded image, and then send it to S3 for storage, but am looking to avoid writing the resized jpeg to the disk and then reloading it for the S3 request. Is there a way to do this completely in memory, with the image data JPEG formatted, saved in a variable? Most people using PHP choose either ImageMagick or Gd2 I've never used Imagemagick; the Gd2 method: <?php // assuming your uploaded file was 'userFileName' if ( ! is_uploaded_file(validateFilePath($_FILES[$userFileName]['tmp_name'])) ) { trigger_error('not an uploaded

How to add text to an image with PHP GD library

爱⌒轻易说出口 提交于 2019-11-27 07:19:53
I have image creation code in image_creator. <?php header("Content-Type: image/jpeg"); $im = ImageCreateFromGif("photo.gif"); $black = ImageColorAllocate($im, 255, 255, 255); $start_x = 10; $start_y = 20; Imagettftext($im, 12, 0, $start_x, $start_y, $black, 'verdana.ttf', "text to write"); Imagejpeg($im, '', 100); ImageDestroy($im); ?> The file for image output is image.php and has below code <html> <head> </head> <body> <img src="http://localhost/image_creator.php"/> </body> </html> When I run image.php, I just get a blank page. Why is it so? Akhilraj N S Use this to add text to image (copied

Merge two PNG images with PHP GD library

六月ゝ 毕业季﹏ 提交于 2019-11-27 06:48:34
问题 Does anybody have a script which can merge two PNG images? With the following conditions: Both images have transparent areas The second image must have 50% opacity ( it is overlaid over the first image ) Here is what I tried to do but without luck: <?php function imagecopymerge_alpha($dst_im, $src_im, $dst_x, $dst_y, $src_x, $src_y, $src_w, $src_h, $pct){ $cut = imagecreatetruecolor($src_w, $src_h); imagecopy($cut, $dst_im, 0, 0, $dst_x, $dst_y, $src_w, $src_h); imagecopy($cut, $src_im, 0, 0,

PHP/GD - Cropping and Resizing Images

一个人想着一个人 提交于 2019-11-27 06:07:40
问题 I've coded a function that crops an image to a given aspect ratio and finally then resizes it and outputs it as JPG: <?php function Image($image, $crop = null, $size = null) { $image = ImageCreateFromString(file_get_contents($image)); if (is_resource($image) === true) { $x = 0; $y = 0; $width = imagesx($image); $height = imagesy($image); /* CROP (Aspect Ratio) Section */ if (is_null($crop) === true) { $crop = array($width, $height); } else { $crop = array_filter(explode(':', $crop)); if

Cropping image in PHP

只谈情不闲聊 提交于 2019-11-27 05:02:05
I'd like crop an image in PHP and save the file. I know your supposed to use the GD library but i'm not sure how. Any ideas? Thanks Andris You could use imagecopy to crop a required part of an image. The command goes like this: imagecopy ( resource $dst_im - the image object , resource $src_im - destination image , int $dst_x - x coordinate in the destination image (use 0) , int $dst_y - y coordinate in the destination image (use 0) , int $src_x - x coordinate in the source image you want to crop , int $src_y - y coordinate in the source image you want to crop , int $src_w - crop width , int

PHP function imagettftext() and unicode

匆匆过客 提交于 2019-11-27 04:26:25
I'm using the PHP function imagettftext() to convert text into a GIF image. The text I am converting has Unicode characters including Japanese. Everything works fine on my local machine (Ubuntu 7.10), but on my webhost server, the Japanese characters are mangled. What could be causing the difference? Everything should be encoded as UTF-8. Broken Image on webhost server: http://www.ibeni.net/flashcards/imagetest.php Copy of correct image from my local machine: http://www.ibeni.net/flashcards/imagetest.php.gif Copy of phpinfo() from my local machine: http://www.ibeni.net/flashcards/phpinfo.php