gd

PHP GD - Merge multiple images in tiled layout

穿精又带淫゛_ 提交于 2020-01-14 06:18:51
问题 I'm working on a class that takes an array of images by src and merges them into a single tiled image, similar to the following image; The only issue is the images provided to the class aren't of set dimensions like in the image above. The following state of the class creates a vertically stacked list of the images without gaps (an example shown below), and calculates the required height of the export image automatically (calculated in $total_height ). I imagine gaps are inevitable in the

Fatal error: Call to undefined function imagefilter()

蹲街弑〆低调 提交于 2020-01-14 05:35:07
问题 What is causing this error? Fatal error: Call to undefined function imagefilter() in /var/www/polaroid.php on line 5 1 <?PHP 2 $img_addr = $_GET['image_address']; 3 $img = imagecreatefromjpeg($img_addr); 4 /* everything works as expected without this line */ 5 imagefilter($img, IMG_FILTER_GRAYSCALE); 6 7 if ($img) 8 { /* I moved the header function here so I can see errors in the browser. If I leave it at the top of the file, the browser expects an image and doesn't print the error messages.

Replace a color with another in an image with PHP

随声附和 提交于 2020-01-12 05:25:27
问题 Can someone help me with a simple script to replace a specific color with another color in an image using PHP? Here is a example (color changed from green to yellow). 回答1: If you meant using GD library in PHP, you should give a check on imagefilter() Steps are: Start with a .PNG image, use white for inner, alpha for outer. Use imagefilter($img, IMG_FILTER_COLORIZE, 0, 255, 0)) Where 0,255,0 is your RGB color (bright green in this example) Save the alpha and print out result. Edit, Working

PHP GD not rendering unicode fonts properly

谁都会走 提交于 2020-01-11 11:17:32
问题 I am having problems in rendering unicode glyphs ( language : Malayalam, Tamil and Hindi) with PHP GD library. Is this something related to the rendering engine of GD library? Any workarounds available ? 回答1: First make sure your fonts contain the desired glyphs (system fonts such as Arial should). Then make sure you convert your parameters to unicode using utf8_decode() if neccessary. 回答2: i have found one try this <?php //error_reporting(0); $text = ("Unreadable text"); $font = "mangal.ttf"

PHP GD not rendering unicode fonts properly

不想你离开。 提交于 2020-01-11 11:15:06
问题 I am having problems in rendering unicode glyphs ( language : Malayalam, Tamil and Hindi) with PHP GD library. Is this something related to the rendering engine of GD library? Any workarounds available ? 回答1: First make sure your fonts contain the desired glyphs (system fonts such as Arial should). Then make sure you convert your parameters to unicode using utf8_decode() if neccessary. 回答2: i have found one try this <?php //error_reporting(0); $text = ("Unreadable text"); $font = "mangal.ttf"

Cannot install GD module on darwin 13.0.1 using cpan

邮差的信 提交于 2020-01-11 09:21:10
问题 I'm having a tough job trying to get GD installed. I'm running a Mas OSX 10.9.2 darwin 13.0.1 When I run this: cpan[1]> install GD perl -MCPAN -e shell I get the follwing error: cpan[1]> install GD Reading '/Users/me/.cpan/Metadata' Database was generated on Sun, 21 Dec 2014 18:53:17 GMT Running install for module 'GD' Running make for L/LD/LDS/GD-2.56.tar.gz Checksum for /Users/me/.cpan/sources/authors/id/L/LD/LDS/GD-2.56.tar.gz ok Scanning cache /Users/me/.cpan/build for sizes .............

PHP - Compress Image to Meet File Size Limit

五迷三道 提交于 2020-01-11 07:55:27
问题 I have to upload image files that meet a max width dimension and max file size. I have the code that checks width size and resizes the image to meet the max image width. However, when I am saving the file I can set the quality imagejpeg( $imgObject , 'resized/50.jpg' , 50 ); //save image and set quality What I would like to do is avoid setting a standard quality, as the images being submitted vary highly from quality and may be low to begin with. The quality of the image should be set as high

Black background on GIF instead of transparency in PHP using imagegif()

风流意气都作罢 提交于 2020-01-11 06:26:06
问题 Edit 2: SUCCESS! many thanks to moycakes! The correct way to convert a PNG to a GIF while retaining transparency goes as follows: $input = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAXwAAAEYCAYAAABfgk2GAAAemklEQVR4Xu2dzYsm13WHe7rHxGATtw1Zu8UMY0wIkv6AoF44ZOEspFWyUytkkRASJG0sgS2NPkCKF5qxMSSboNbOu4xJcAxZaJRNlhqRVYaZpPUPSC2wiYmm38k5rS75delW1b1V9+Pcuk9BMR/vrXvPfc6p33veU7eqLu2wQQACEIBAEwQuNTFLJgkBCEAAAjsIPkEAAQhAoBECCH4jjmaaEIAABBB8YgACEIBAIwQQ

Image getting rotated automatically on upload

家住魔仙堡 提交于 2020-01-09 10:05:09
问题 I'm trying to upload a base64 encoded image and save after decoding it. Image is getting uploaded and saved, and I can access it using a URL and everything..but the image gets rotated by 90 degrees anti-clockwise and I have no idea WHY!! The place where I get the encoded data is fine, as putting it in <img /> works fine! function saveImageData($base64Data) { $base64_decoded = base64_decode($base64Data); $im = imagecreatefromstring($base64_decoded); if ($im !== false) { $imagepath = '/public

解决Onethink验证码不显示问题

为君一笑 提交于 2020-01-08 21:45:21
【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>> 常见的GD未安装及BOM问题办法就不细说了,度娘上答案较多。 可是我遇到的验证码不显示不是这类原因导致的,反复检查最后才确定了是FreeType字体引擎未安装的原因。 首先,打开TP调试模式,右键打开验证码错误图标,会发现标志性的报错, call to undefined function Think/imagettftext 单独php探针一下,环境中的确不存在这个函数。查php手册,发现该函数需要GD和freetype支持,GD我是确认安装的,freetype没有安装,起先一度以为unbuntu下apt-get搜索到并安装一个libfreetype6-dev包就行了,可是问题依然存在,于是一段时间内竟然忽略了这个真正的原因。 最后才明确到问题的确是在freetype 上,只是我的安装freetype的方法不对。 大家如果排除了GD和bom问题,验证码依然不存在,就可以在phpinfo查看GD节区,看看是否有三行Freetype的描述(广义来说,其实这也算GD支持不完整的问题),如果没有,就应该是没有安装freetype了 解决方法如下: 先去Freetype官网http://www.freetype.org/下载源码 tar -jxvf freetpe.tar.gz cd freetype.