gd

PHP: create image with ImagePng and convert with base64_encode in a single file?

怎甘沉沦 提交于 2019-12-18 03:56:44
问题 I have created an image with ImagePng(). I dont want it to save the image to the file system but want to output it on the same page as base64 encode inline Image, like print '<p><img src="data:image/png;base64,'.base64_encode(ImagePng($png)).'" alt="image 1" width="96" height="48"/></p>'; which does not work. Is this possible in a single PHP file at all? Thanks in advance! 回答1: The trick here will be to use output buffering to capture the output from imagepng() , which either sends output to

How can I add jpeg support to Heroku PHP buildpack

谁说胖子不能爱 提交于 2019-12-18 03:49:08
问题 I am developping an app using Heroku. I will need to manipulate images but unfortunately jpeg is not supported by default. I spoke with support and here is their answer: "We unfortunately don't support jpeg by default. But the good news is that we open sourced our PHP buildpack, so hopefully the community will be able to bring that in. In case you're interested, the buildpack is here: https://github.com/heroku/heroku-buildpack-php" I know I need to add --with-jpeg just before the --with-gd in

How can I add jpeg support to Heroku PHP buildpack

核能气质少年 提交于 2019-12-18 03:48:02
问题 I am developping an app using Heroku. I will need to manipulate images but unfortunately jpeg is not supported by default. I spoke with support and here is their answer: "We unfortunately don't support jpeg by default. But the good news is that we open sourced our PHP buildpack, so hopefully the community will be able to bring that in. In case you're interested, the buildpack is here: https://github.com/heroku/heroku-buildpack-php" I know I need to add --with-jpeg just before the --with-gd in

PHP GD bundled extension without recompiling PHP - solution

℡╲_俬逩灬. 提交于 2019-12-18 03:47:16
问题 The bundled extension offer a lot of functionality. I have spent a lot of time how to compile extension for my version of PHP. So there are instructions. 回答1: 0, Install PHP development package. Also You should have installed PHP with GD extension (but not bundled) sudo apt-get install php5-dev 1, Download source code of used PHP (for me 5.6.18) wget http://cz2.php.net/get/php-5.6.18.tar.gz/from/this/mirror -O php-5.6.18.tar.gz 2, Extract archive tar -xzf php-5.6.18.tar.gz 3, Go to the source

How can I upload an image from a URL in PHP

青春壹個敷衍的年華 提交于 2019-12-18 03:01:31
问题 In PHP using GD or imagemagick how can I uplaod a photo from a URL, I want to build a function that I can pass in a few parameters and uplaod the image, I can currentyl uplaod a big image, resize it smaller, then resize some more thumbnails off it and save all into there locations from 1 image but I would like to add the ability to get an image from a URL and then run my code on it to resize and make thumbs. Would I use curl or something else any example or ideas would be greatly appreciated

imagepng() and transparency in GD library with PHP

丶灬走出姿态 提交于 2019-12-18 02:19:43
问题 When using the function imagepng() in PHP, how can I make sure the images that I save are saved with a transparent background? 回答1: Here is an example of the imagecolortransparent function (if it helps): <?php // Create a 55x30 image $im = imagecreatetruecolor(55, 30); $red = imagecolorallocate($im, 255, 0, 0); $black = imagecolorallocate($im, 0, 0, 0); // Make the background transparent imagecolortransparent($im, $black); // Draw a red rectangle imagefilledrectangle($im, 4, 4, 50, 25, $red);

How to check if an image has transparency using GD?

杀马特。学长 韩版系。学妹 提交于 2019-12-17 19:33:58
问题 How do I check if an image has transparent pixels with php's GD library? 回答1: It doesn't look like you can detect transparency at a glance. The comments on the imagecolorat manual page suggest that the resulting integer when working with a true-color image can actually be shifted four times total, with the fourth being the alpha channel (the other three being red, green and blue). Therefore, given any pixel location at $x and $y , you can detect alpha using: $rgba = imagecolorat($im,$x,$y);

Good way to identify similar images? [closed]

折月煮酒 提交于 2019-12-17 17:25:16
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 months ago . I've developed a simple and fast algorithm in PHP to compare images for similarity. Its fast (~40 per second for 800x600 images) to hash and a unoptimised search algorithm can go through 3,000 images in 22 mins comparing each one against the others (3/sec). The basic overview is

imagecreatefromjpeg and similar functions are not working in PHP

浪子不回头ぞ 提交于 2019-12-17 15:46:18
问题 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. 回答1: 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

PHP allocate color without image resource

北慕城南 提交于 2019-12-17 14:54:35
问题 Can you allocate a color in PHP GD without an image resource? It should be possible because really an allocated color is a number, right? $im = imagecreatetruecolor(100, 100); $col = imagecolorallocate($im, 255, 0, 0); print $col."<br/>"; $col2 = imagecolorallocate($im, 255, 0, 0); print $col2."<br/>"; $im2 = imagecreatetruecolor(600, 100); $col3 = imagecolorallocate($im, 255, 0, 0); print $col3; This prints out: 16711680 16711680 16711680 I guess what the real question is how 255, 0, and 0