gd

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

不想你离开。 提交于 2019-11-26 22:59:10
问题 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. 回答1: <?php /* Resizes an image and converts it to PNG returning the PNG data as a string */ function imageToPng(

Have GD get image from binary string

断了今生、忘了曾经 提交于 2019-11-26 22:26:34
问题 I have a database that stores images in a MySQL BLOB field. I setup a script that selects and displays the images based on an ID in the URL, and I also made it so if you append ?resize=800x600, it would resize the image (in this case, to 800x600). The host that I use doesn't have Imagemagick installed and won't let me do it myself, so I need to use PHP's GD library to resize the image. But I've yet to find a function like Imagick's readImageBlob() , so I can't edit the binary string that I

PHP GD Use one image to mask another image, including transparency

*爱你&永不变心* 提交于 2019-11-26 21:59:22
I am trying to create a PHP script that takes an image: http://i.stack.imgur.com/eNvlM.png and then applies a PNG image: http://i.stack.imgur.com/iJr2I.png as a mask. The end result needs to maintain transparency: http://i.stack.imgur.com/u0l0I.png If at all possible I want to do this in GD, ImageMagick is not really an option right now. How would I go about this? phalacee's post (in "PHP/GD, how to copy a circle from one image to another?") seems to be along the right lines but I specifically need to use an image as a mask, not a shape. Matt, If you make your png with the oval white fill on

PHP - Place an image over another image

被刻印的时光 ゝ 提交于 2019-11-26 21:54:18
问题 I want to place an image over another image using php. I have two images. One is a photo. And other one is a image, of fixed size, full white. We can call this as frame. So what i need is place the photo in the middle of the frame (white image) and then save it. Can anyone pls help me? 回答1: to do this kind of work, you need to use GD library or ImageMagic this code work with GD library $photo_to_paste="image_to_paste.jpg"; //image 321 x 400 $white_image="white_image.jpg"; //873 x 622 $im =

How can I take a screenshot of a website with PHP and GD?

点点圈 提交于 2019-11-26 21:44:53
问题 How can I create a screenshot of a website using PHP and the GD library. 回答1: While you might be able to do something with imagegrabscreen or imagegrabwindow you'd only be able to use it on a Windows box, and even then it would be tricky. You'd have to open a browser window to the specified url (you could do that with exec ) and grab a screenshot using the aforementioned methods. Here's an example from the manual entry for imagegrabwindow: <?php $browser = new COM("InternetExplorer

How can I merge 3 images into 1 image via PHP?

旧街凉风 提交于 2019-11-26 21:07:21
问题 I really cannot find a way to successfully do it.. I've searched google for this and it either has black shades around the images or all the images don't overlap. Could you please help? I am alright at PHP; I'd give myself a 2/5.. I would really appreciate if someone would be willing to help me out. I'm looking for a simple api that goes something like: $color=$_GET['color']; $face=$_GET['face']; $hat=$_GET['hat']; echo '<img src="avatar.php?color=$color&face=$face&hat=$hat">'; Thanks for any

Programmatically create image from web-page or a single DIV

怎甘沉沦 提交于 2019-11-26 20:59:50
问题 Is there any way to programmatically create (client or server side (PHP)) a image from a specific DIV or a complete (web) page? I'm currently creating a web-site for free coupons and the idea is when the end-user clicks on the "Print" button, the app opens a new tab/window with all the selected coupons as a single image (JPG, PNG or etc..) in A4 format ready for printing. Each coupons has it's own data (Article name, price, description etc..) so I need it to be done programmatically over a

Issues porting PHP/GD wrapper to Imagick

◇◆丶佛笑我妖孽 提交于 2019-11-26 20:57:58
问题 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

install php70-gd on ubuntu

自闭症网瘾萝莉.ら 提交于 2019-11-26 20:23:14
问题 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? 回答1: 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

Detect main colors in an image with PHP

萝らか妹 提交于 2019-11-26 19:40:33
I am trying to replicate the functionality that Dribbble.com does with detecting the predominant colors in an Image. In the image below you can see a screenshot from Dribbble.com that shows the 8 predominant colors in the image to the left. Here is the actual page in the image http://dribbble.com/shots/528033-Fresh-Easy?list=following I need to be able to do this in PHP, once I get the colors I need I will save them to a database so the processing does not need to be run on every page load. After some research on how to get these colors out of an Image, some people said you simply examine an