gd

Getting imagegrabscreen to work

[亡魂溺海] 提交于 2019-11-27 04:05:38
问题 I'm trying to get imagegrabscreen (a GD function) to work with my Apache/Vista PC. I'm using the following code: <?php $im = imagegrabscreen(); header('Content-type: image/png'); imagepng($im); imagedestroy($im); ?> At the moment I get a solid black image, the size of my secondary monitor (1024*768). I'm using Apache 2.2, runing as a service, Vista SP1 with UAC off, PHP 5.2.8 and GD (information below). I've followed the note on the imagegrabscreen page about allowing Apache access to the

Crop or mask an image into a circle

核能气质少年 提交于 2019-11-27 03:52:10
What is the best way to crop or mask an image into a circular shape, using either ImageMagick or GD libraries? (Note, solution exists on "other" Q&A sites, but not StackOverflow) tom Here is one way with ImageMagick that will acomplish this without using a mask: convert -size 200x200 xc:none -fill walter.jpg -draw "circle 100,100 100,1" circle_thumb.png Jonathan Hell For those who need to do this in pure PHP using Imagick , you will need to refer to this question : circularize an image with imagick Hope this will help. J. For those who wants a solution in PHP, providing the picture already

How to get image resource size in bytes with PHP and GD?

走远了吗. 提交于 2019-11-27 03:30:10
问题 I'm resizing images with php gd. The result is image resources that i want to upload to Amazon S3. It works great if i store the images on disk first but i would like to upload them directly from memory. That is possible if i just know the bytesize of the image. Is there some way of getting the size (in bytes) of an gd image resource? 回答1: You could use PHP's memory i/o stream to save the image to and subsequently get the size in bytes. What you do is: $img = imagecreatetruecolor(100,100); //

How to encode an image resource to base64?

冷暖自知 提交于 2019-11-27 03:29:24
问题 I was wondering if there's a way to encode an image to a base64 if it was a resource for example if I loaded an image using GD $image = imagecreatefromjpeg("captcha/$captcha-$num.jpg"); // Add some filters imagefilter($image, IMG_FILTER_PIXELATE, 1, true); imagefilter($image, IMG_FILTER_MEAN_REMOVAL); If this was my code and instead of saving the image and displaying it using <img src='someimage.jpg'> I wanted to display it as a data URI without having to save it, like <img data='src="data

PHP GD image perspective

我与影子孤独终老i 提交于 2019-11-27 02:58:45
问题 Hi is it possible to transform an images perspective... so it's new shape is an isosceles trapezoid? I saw a solution using imagemagick, but that would involve possibly rewriting my entire image manipulation script... (not to mention learning, of which i'm allergic) 回答1: GD does not support 3D image manipulations :( The solution using ImageMagick is not complex: http://valokuva.org/?p=112 回答2: I have improved the function that James have posted. Added: vertical / horizontal perspective

Convert png file to ico with PHP

给你一囗甜甜゛ 提交于 2019-11-27 02:50:48
问题 I would like to create a PHP script that convert a png file to an ico file. Is it possible to do it just with PHP ? How ? Thanks !!! 回答1: The recently uploaded https://github.com/chrisbliss18/php-ico creates valid ICO files including multiple embedded resolutions from PNG files and other file formats using only PHP and the GD library. 回答2: After some googling and light experimentation, it appears that an .ico file is basically a BMP with another file extension. I believe the ICO format

imageantialias call to undefined function error with GD installed

守給你的承諾、 提交于 2019-11-27 02:37:23
问题 I need help with a php script. It is a CMS that has been implemented into a website. When trying to add a new product IMAGE or trying to edit current images, I am getting the following error: Fatal error: Call to undefined function imageantialias() in /home/mounts/home/m/mclh/web/admin/library/functions.php on line 233 This is my code for that area: if ($tmpDest['extension'] == "gif" || $tmpDest['extension'] == "jpg") { $destFile = substr_replace($destFile, 'jpg', -3); $dest =

Rounded transparent _smooth_ corners using imagecopyresampled() PHP GD

懵懂的女人 提交于 2019-11-27 01:56:43
问题 I need a script which makes rounded transparent corners on supplied image. I've found one and it works good except the one thing: the applied corners do not look smooth. The imageantialias() throws Fatal Error since PHP is running on Debian and re-compiling it is not an option. The trick I've found to make those corners look smooth is resizing the image with imagecopyresampled() as the following: prepare the image; imagecopyresample it to 10x size; draw corners with a special colour; make

Put PNG over a JPG in PHP [duplicate]

℡╲_俬逩灬. 提交于 2019-11-27 01:08:15
问题 This question already has an answer here: Transparent PNG over JPG in PHP 2 answers I want to do the following in PHP: I have two images, a jpg and a png. I want to resize the jpg to the same size as the png then put the png on top. The PNG has transparency so I would like to preserve that so the jpg shows underneath. If anyone could help that would be great! Thanks 回答1: <? $png = imagecreatefrompng('./mark.png'); $jpeg = imagecreatefromjpeg('./image.jpg'); list($width, $height) =

Convert GD output to base64

这一生的挚爱 提交于 2019-11-27 00:44:41
问题 Well, my question is very simple, i just wanna convert the output of imagepng /imagejpg to base64, how i can do this ? the correctly way is with capturing output buffer ? thanks. 回答1: imagejpeg / imagepng doesn't return any data, they write the image data directly to the output stream (or to a file). If you'd like to capture this data encoded as base64 the easiest method is to use PHPs Output Control Functions, and then use base64_encode on the $image_data . ob_start (); imagejpeg ($img);