gd

Why when i rotate the image black borders appear? PHP GD

北城以北 提交于 2019-12-11 01:05:54
问题 This code generates two images using GD and rotates one of them. When I rotate the image black borders begin to appear. Anyone have an idea of how to resolve this? <?php $im = imagecreatetruecolor(300, 400); $white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 000, 000, 000); $black1 = imagecolorallocate($im, 001, 001, 001); $grey = imagecolorallocate($im, 230, 230, 230); $font_file = './arial.ttf'; $rotate=45; imagefilledrectangle($im, 0, 0, 300, 400, $black);

php_network_getaddresses: getaddrinfo failed

…衆ロ難τιáo~ 提交于 2019-12-11 00:54:34
问题 I am getting this error in all the functions of Image GD library. $im = @imagecreatefromjpeg("src/bg.jpg") or die('Cannot Initialize new GD image stream'); function copyImage1($im, $dp1_name, $x1, $y1){ $dp1 = imagecreatefromjpeg($dp1_name); list($w1, $h1) = getimagesize($dp1_name); imagecopy($im, $dp1, 35, 130, 0, 0, $w1, $h1); } function copyImage2($im, $dp2_name, $x2, $y2){ $dp2 = imagecreatefromjpeg($dp2_name); list($w2, $h2) = getimagesize($dp2_name); imagecopy($im, $dp2, 618, 125, 0, 0,

Generated image using PHP and GD is being cut off

一世执手 提交于 2019-12-11 00:49:53
问题 This is only happening on the live server. On multiply development servers the image is being created as expected. LIVE: Red Hat $ php --version PHP 5.2.6 (cli) (built: May 16 2008 21:56:34) Copyright (c) 1997-2008 The PHP Group Zend Engine v2.2.0, Copyright (c) 1998-2008 Zend Technologies GD Support => enabled GD Version => bundled (2.0.34 compatible) DEV: Ubuntu 8 $ php --version PHP 5.2.4-2ubuntu5.3 with Suhosin-Patch 0.9.6.2 (cli) (built: Jul 23 2008 06:44:49) Copyright (c) 1997-2007 The

PHP GD library resize photo

走远了吗. 提交于 2019-12-11 00:05:14
问题 I am attempting to create thumbnails of photos using PHP's GD library. Here are the steps I am taking. Create GD Image resource. Get height and width of image create a blank gd image resource at 100 pixels high by appropriate width copy resource image to blank gd image resource and save both images Here is my code: private function getExtension($filename) { $position=strrpos($filename, '.'); $extension = strtolower(substr($filename, $position+1)); if ($extension == "jpg") { $extension = "jpeg

Should I use ImageMagick or GD2 with ImageAPI in Drupal?

匆匆过客 提交于 2019-12-10 21:06:28
问题 Should I use ImageMagick, or GD2, with ImageAPI in Drupal? What are the pros and cons? 回答1: ImageMagick is faster can handle many more formats the imagick binary works outside PHP's memory limit (As far as I know - please correct me if I'm wrong) can at least get something out of a CMYK file (though the result often looks like someone puked on your source image, colour profile handling is terrible) has no problems resizing transparent GIFs which was an issue in some versions of GD is better

PHP Image URL from /buildimg.php?1=2816 to /picture_2816.png?

早过忘川 提交于 2019-12-10 20:17:57
问题 How can I change the URL from a PHP extension to a PNG extension? I am making an image generator for users to post their score on a test on forums. The main targeted forum, though, does not allow php extensions in images. How can I change this URL: http://everythingtutorials.org/noobtest/buildimg.php?1=2816 to something like this: http://everythingtutorials.org/noobtest/picture_2816.png 回答1: What you're asking is done at the webserver level, before the request reaches PHP. You need to

How to get GIF transparency color for saving with GD?

左心房为你撑大大i 提交于 2019-12-10 18:54:26
问题 My GD wrapper works like charm with JPEG and PNG images, however when using GIF image the resulting image loses transparency. Further search suggests i have to use imagecolortransparent (sets the transparent color) after getting color identifier with: imagecolorallocate (resource $image , int $red , int $green , int $blue) . So question is: how can i get original transparecy color (RGB)? 回答1: Assuming that the GIF image is loaded into resource $image... try the following $index_of_transparent

php gd : image cannot be displayed because it contains errors

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 17:43:01
问题 I'm very annoyed with this error : If I comment out the require_once'../class/myclass.class.php'; the image is displayed. If I un-comment my line calling myclass.class.php, I have this message: "The image "http://..." cannot be displayed because it contains errors." My code is simple: myclass.class.php : <?php class myclass { public function getPanelData( $model ){ $aFieldsData = array( 'PAN35'=>array( 'col'=>1, 'row'=>3, 'v-font'=>10, 'v-marge-top'=>0, 'v-marge-right'=>1, 'v-marge-bottom'=>0

PHP crop image in shape other than square like oval shape or round

北城以北 提交于 2019-12-10 17:12:11
问题 I want to crop images in PHP. Cropping in rectangular shape is all common and easy to do. Can you guide me that how i can crop image in shape other than square like in oval or round shape. 回答1: You can actually do that with ImageMagick ... See Crop or mask an image into a circle and Crop image into circle and add border for good examples 回答2: In addition to the previous answer, you can even blur the border with Image Magick's vignette effect, look for vignetteImage method. 来源: https:/

imagecreatefromstring using image with data:image/png;base64,

。_饼干妹妹 提交于 2019-12-10 16:25:36
问题 I've an image stored as string that starts with: data:image/png;base64, I need to convert it to a normal image for use it with GD. I tried imagecreatefromstring() but it seems to accept only images without the data:image/etc pefix. How can I do? 回答1: $exploded = explode(',', $data, 2); // limit to 2 parts, i.e: find the first comma $encoded = $exploded[1]; // pick up the 2nd part $decoded = base64_decode($encoded); $img_handler = imagecreatefromstring($decoded); 来源: https://stackoverflow.com