gd

Issues porting PHP/GD wrapper to Imagick

北城余情 提交于 2019-11-27 22:12:42
I've recently discovered that Imagick can support color profiles and thus produce images of better quality compared to GD (see this question / answer for more details), so I'm trying to port my GD wrapper to use the Imagick class instead, my current GD implementation looks like this: function Image($input, $crop = null, $scale = null, $merge = null, $output = null, $sharp = true) { if (isset($input, $output) === true) { if (is_string($input) === true) { $input = @ImageCreateFromString(@file_get_contents($input)); } if (is_resource($input) === true) { $size = array(ImageSX($input), ImageSY(

install php70-gd on ubuntu

ε祈祈猫儿з 提交于 2019-11-27 21:46:20
Recently the new php7 has been released. However, when I am trying to install the gd package, the library can not be found. I have tried through sudo apt-get install php70-gd and sudo apt-get install php70-php-gd Does anybody have an idea if gd is available for php 7? PHP7 packages for Ubuntu including php7.0-gd can be installed via PPA for PHP by Ondřej Surý : sudo add-apt-repository ppa:ondrej/php sudo apt-get update Next, install the desired version: sudo apt-get install php7.0-gd # or sudo apt-get install php7.1-gd # or sudo apt-get install php7.2-gd EDIT: As MacroMan stated , under Ubuntu

How do I resize and convert an uploaded image to a PNG using GD?

大憨熊 提交于 2019-11-27 20:50:15
I want to allow users to upload avatar-type images in a variety of formats ( GIF, JPEG, and PNG at least ), but to save them all as PNG database BLOBs . If the images are oversized, pixelwise, I want to resize them before DB-insertion. What is the best way to use GD to do the resizing and PNG conversion? Edit: Sadly, only GD is available on the server I need to use, no ImageMagick . <?php /* Resizes an image and converts it to PNG returning the PNG data as a string */ function imageToPng($srcFile, $maxSize = 100) { list($width_orig, $height_orig, $type) = getimagesize($srcFile); // Get the

PHP GD: How to get imagedata as binary string?

社会主义新天地 提交于 2019-11-27 20:34:32
I'm using a solution for assembling image files to a zip and streaming it to browser/Flex application. (ZipStream by Paul Duncan, http://pablotron.org/software/zipstream-php/ ). Just loading the image files and compressing them works fine. Here's the core for compressing a file: // Reading the file and converting to string data $stringdata = file_get_contents($imagefile); // Compressing the string data $zdata = gzdeflate($stringdata ); My problem is that I want to process the image using GD before compressing it. Therefore I need a solution for converting the image data (imagecreatefrompng) to

imagecreatefromjpeg and similar functions are not working in PHP

一笑奈何 提交于 2019-11-27 19:34:20
I’ve searched for this and the solutions provided in past questions are completely incomprehensible to me. Whenever I run functions like imagecreatefromjpeg , I get this: Fatal error: Call to undefined function imagecreatefromjpeg() ... I’m working on a new install of PHP; my last installation never had this problem. I don’t get what’s going on. Install GD Library Which OS you are using? http://php.net/manual/en/image.installation.php Windows http://www.dmxzone.com/go/5001/how-do-i-install-gd-in-windows/ Linux http://www.cyberciti.biz/faq/ubuntu-linux-install-or-add-php-gd-support-to-apache/

PHP GD Allowed memory size exhausted

亡梦爱人 提交于 2019-11-27 19:19:25
问题 I'm trying to process a directory of JPEG images (roughly 600+, ranging from 50k to 500k) using PHP: GD to resize and save the images but I've hit a bit of a snag quite early in the process. After correctly processing just 3 images (30K, 18K and 231K) I get a Allowed memory size of 16777216 bytes exhausted PHP Fatal error. I'm cycling through the images and calling the code below: list($w, $h) = getimagesize($src); if ($w > $it->width) { $newwidth = $it->width; $newheight = round(($newwidth *

Create Image From Url Any File Type

空扰寡人 提交于 2019-11-27 18:51:23
I know of imagecreatefromgif() , imagecreatefromjpeg() , and imagecreatefrompng() but is there a way to create an image resource (for png preferably) from a url of any type of valid image? Or do you have to determine the file type and then use the appropriate function? When I say url I mean something like http://sample.com/image.png , not a data url Maybe you want this: $jpeg_image = imagecreatefromfile( 'photo.jpeg' ); $gif_image = imagecreatefromfile( 'clipart.gif' ); $png_image = imagecreatefromfile( 'transparent_checkerboard.PnG' ); $another_jpeg = imagecreatefromfile( 'picture.JPG' ); //

Can I detect animated gifs using php and gd?

ぃ、小莉子 提交于 2019-11-27 17:58:41
I'm currently running into some issues resizing images using GD. Everything works fine until i want to resize an animated gif, which delivers the first frame on a black background. I've tried using getimagesize but that only gives me dimensions and nothing to distinguish between just any gif and an animated one. Actual resizing is not required for animated gifs, just being able to skip them would be enough for our purposes. Any clues? PS. I don't have access to imagemagick. Kind regards, Kris Davide Gualano There is a brief snippet of code in the PHP manual page of the imagecreatefromgif()

Combine 2-3 transparent PNG images on top of each other with PHP

末鹿安然 提交于 2019-11-27 17:32:12
I am working on a custom avatar system for a project, but I have never really done much with the image side of PHP. I assume I need to use GD in some way, but I have no idea where to even start. Basically, there are a bunch of pre-made transparent PNG images. Users can select 2-3 of them to customize their avatar, and I want to be able to take these images and make a single image out of them to be stored in a folder. $image_1 = imagecreatefrompng('image_1.png'); $image_2 = imagecreatefrompng('image_2.png'); imagealphablending($image_1, true); imagesavealpha($image_1, true); imagecopy($image_1,

Transparent Circle Cropped Image with PHP

て烟熏妆下的殇ゞ 提交于 2019-11-27 16:55:37
问题 I want to crop a circle image using PHP but it seems that my new image have some transparent pixels. Of course, I want ONLY the outside area of the ellipse to have background transparent My code is listed below: $image = imagecreatetruecolor($this->dst_w, $this->dst_h); imagealphablending($image,true); imagecopy ( $image , $image_s , 0, 0, $this->src_x, $this->src_y, $this->dst_w, $this->dst_h ); $mask = imagecreatetruecolor($this->src_x, $this->src_y); $mask = imagecreatetruecolor($this->dst