gd

Create Image From Url Any File Type

倾然丶 夕夏残阳落幕 提交于 2019-12-17 10:33:16
问题 I know of imagecreatefromgif(), imagecreatefromjpeg(), and imagecreatefrompng() but is there a way to create an image resource (for png preferably) from a url of any type of valid image? Or do you have to determine the file type and then use the appropriate function? When I say url I mean something like http://sample.com/image.png , not a data url 回答1: Maybe you want this: $jpeg_image = imagecreatefromfile( 'photo.jpeg' ); $gif_image = imagecreatefromfile( 'clipart.gif' ); $png_image =

Cropping image in PHP

二次信任 提交于 2019-12-17 07:37:13
问题 I'd like crop an image in PHP and save the file. I know your supposed to use the GD library but i'm not sure how. Any ideas? Thanks 回答1: You could use imagecopy to crop a required part of an image. The command goes like this: imagecopy ( resource $dst_im - the image object , resource $src_im - destination image , int $dst_x - x coordinate in the destination image (use 0) , int $dst_y - y coordinate in the destination image (use 0) , int $src_x - x coordinate in the source image you want to

Cropping image in PHP

一曲冷凌霜 提交于 2019-12-17 07:36:30
问题 I'd like crop an image in PHP and save the file. I know your supposed to use the GD library but i'm not sure how. Any ideas? Thanks 回答1: You could use imagecopy to crop a required part of an image. The command goes like this: imagecopy ( resource $dst_im - the image object , resource $src_im - destination image , int $dst_x - x coordinate in the destination image (use 0) , int $dst_y - y coordinate in the destination image (use 0) , int $src_x - x coordinate in the source image you want to

Crop whitespace from image in PHP

六月ゝ 毕业季﹏ 提交于 2019-12-17 05:45:14
问题 Is it possible to remove the whitespace surrounding an image in PHP? NOTE: to clarify I mean something like photoshops trim feature. Thanks. 回答1: To trim all whitespace, as you call it, surrounding the interesting part of the image, first we find out where the "whitespace" stops, and then we copy everything inside of those borders. //load the image $img = imagecreatefromjpeg("http://ecx.images-amazon.com/images/I/413XvF0yukL._SL500_AA280_.jpg"); //find the size of the borders $b_top = 0; $b

How to install Imagick/imagemagick PHP extension on windows 7

喜夏-厌秋 提交于 2019-12-17 04:21:11
问题 How to install image magic in Windows 7. I followed these instruction To install IMagick on Windows XP (php 5.2.x) download and install ImageMagick-6.5.8-7 Q16-windows-dll.exe http://www.imagemagick.org/download/binaries/ ImageMagick-6.5.8-7-Q16-windows-dll.exe download php_imagick_dyn-Q16.dll from: http://valokuva.org/outside-blog-content/ imagick-windows-builds/080709/ copy dll to [PHP]/extension dir and rename it to php_imagick.dll You have to edit your php.ini file and add new extension

Cannot force install GD with cpan/cpanm

半城伤御伤魂 提交于 2019-12-14 02:38:47
问题 I have looked and seen similar issues posted but am unable to get GD working. the following error arises with libgd and libpng installed ... clang -c -I/usr/local/include -arch i386 -arch x86_64 -g -pipe -fno-common -DPERL_DARWIN -fno-strict-aliasing -fstack-protector -I/usr/local/include -Wformat=0 -Os -DVERSION=\"2.50\" -DXS_VERSION=\"2.50\" "-I/System/Library/Perl/5.12/darwin-thread-multi-2level/CORE" -DHAVE_FT -DHAVE_GIF -DHAVE_ANIMGIF -DVERSION_33 -DHAVE_UNCLOSEDPOLY -DHAVE_FTCIRCLE GD.c

Image Resizing in (PHP/GD)

倾然丶 夕夏残阳落幕 提交于 2019-12-14 00:29:16
问题 I'm looking for help/suggestions in finding the most efficient way to resize an image to be as small as possible using PHP/GD while preserving the aspect ratio of the original image but ensuring the the resized image is bigger than a defined minimum width & height. For example, the resized image must have a width >= 400 and a height >= 300 but should be as close to those dimensions as possible while maintaining the original aspect ratio. Such that a "landscape" image would have an ideal

PHP GD Library output an image and text content on same page

佐手、 提交于 2019-12-14 00:15:06
问题 I am trying to output an image to a browser and then output HTML (not directly related to the image) on the same page. Is this possible? I am having a heck of a time figuring it out. Here is my code I have been messing with: <?php function LoadJpeg($imgname){ /* Attempt to open */ $im = @imagecreatefromjpeg($imgname); /* See if it failed */ if(!$im){ /* Create a black image */ $im = imagecreatetruecolor(150, 30); $bgc = imagecolorallocate($im, 255, 255, 255); $tc = imagecolorallocate($im, 0,

Browser does not display PNG image

丶灬走出姿态 提交于 2019-12-13 21:32:52
问题 I want to use the GD libs, which seems installed but I can't use it. I look at my gd installation with php_info(); It returns me this: Then I tried this: <pre> <?php print_r(gd_info())?> </pre> Which returns this: Array ( [GD Version] => bundled (2.0.34 compatible) [FreeType Support] => 1 [FreeType Linkage] => with freetype [T1Lib Support] => 1 [GIF Read Support] => 1 [GIF Create Support] => 1 [JPEG Support] => 1 [PNG Support] => 1 [WBMP Support] => 1 [XPM Support] => [XBM Support] => 1 [JIS

imagettftext and the euro sign

久未见 提交于 2019-12-13 15:46:48
问题 I'm using imagettftext to generate a image (I've tried imagefttext as well) but I cannot display the EURO Sign. Look at how it makes it! The font is Myriad and in Photoshop the sign looks fine. 回答1: You can always just make an image of a euro sign (with Photoshop) and substitute it with GD. Not really a solution but at least something that works. 来源: https://stackoverflow.com/questions/6226231/imagettftext-and-the-euro-sign