gdlib

How to convert PNG to 8-bit PNG using PHP GD library

久未见 提交于 2019-11-30 09:27:41
I want to write a routine which takes PNG image path as parameter and convert that image into 8-bit PNG image. I need to use PHP GD library for this. To convert any PNG image to 8-bit PNG use this function, I've just created function convertPNGto8bitPNG () function convertPNGto8bitPNG ($sourcePath, $destPath) { $srcimage = imagecreatefrompng($sourcePath); list($width, $height) = getimagesize($sourcePath); $img = imagecreatetruecolor($width, $height); $bga = imagecolorallocatealpha($img, 0, 0, 0, 127); imagecolortransparent($img, $bga); imagefill($img, 0, 0, $bga); imagecopy($img, $srcimage, 0,

Writing Hindi Fonts with GD Library do not render as desired

白昼怎懂夜的黑 提交于 2019-11-30 07:17:39
问题 If I want to write the following text on the image: दीक्षा शिक्षा क्या क्या हो गया! Then it does not not give the expected result but instead is printing out text on the picture as below. I have tried almost all the devanagari ttf and unicode fonts available for Hindi. Here is the code: $quote="दीक्षा शिक्षा क्या क्या हो गया!"; imagettftext($new_pic, $fontsize, 0, 170, 155-$hidd/2, $color, $font, $quote); Any help will be very much appreciated. 回答1: I had the same problem and came up with a

How to create an image with transparent background

微笑、不失礼 提交于 2019-11-30 03:58:05
How to create an image with GDlib with a transparent background? header('content-type: image/png'); $image = imagecreatetruecolor(900, 350); imagealphablending($image, true); imagesavealpha($image, true); $text_color = imagecolorallocate($image, 0, 51, 102); imagestring($image,2,4,4,'Test',$text_color); imagepng($image); imagedestroy($image); Here the background is black You have to use imagefill() and fill that with allocated color ( imagecolorallocatealpha() ) that have alpha set to 0. As @mvds said, "allocating isn't necessary", if it is a truecolor image (24 or 32bit) it is just an integer

Face detection in PHP

♀尐吖头ヾ 提交于 2019-11-30 00:32:55
Does anybody know of a good way to do face detection in PHP? I came across some code here that claims to do this, but I can't seem to get it to work properly. I'd like to make this work (even though it will be slow) and any help you can give me would be really appreciated. Here's the code from the link: <?php // as published by the Free Software Foundation; either version 2 // of the License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS

Convert image format PNG to JPEG without saving to disk - PHP

ⅰ亾dé卋堺 提交于 2019-11-29 17:27:12
I am taking a PNG image from a url as below. I want to convert the PNG image to JPEG without saving disk with PHP. Finally I want to assign JPEG image to $content_jpg variable. $url = 'http://www.example.com/image.png'; $content_png = file_get_contents($url); $content_jpg=; You want to use the gd library for this. Here's an example which will take a png image and output a jpeg one. If the image is transparent, the transparency will be rendered as white instead. <?php $file = "myimage.png"; $image = imagecreatefrompng($file); $bg = imagecreatetruecolor(imagesx($image), imagesy($image));

Ida pro gragh output batch mode

点点圈 提交于 2019-11-29 16:27:59
Can anyone let me know how we are going to output all the subroutine's graphs in batch mode suing IDC . i.e. I have 447 subroutine's and wanna be output them all and I would like to make sure I first retrieve all the routines address automatically, cuz by knowing the address I can simply use GenFuncCall . P.S: Is this the only cfg that I can get from Ida Pro given a binary dis-assembled file? If you just want the address of all known functions in the IDB, you could use something like this using IDAPython (just an example): def main(): for count, func_ea in enumerate(Functions()): if func_ea ==

How to convert PNG to 8-bit PNG using PHP GD library

牧云@^-^@ 提交于 2019-11-29 14:27:48
问题 I want to write a routine which takes PNG image path as parameter and convert that image into 8-bit PNG image. I need to use PHP GD library for this. 回答1: To convert any PNG image to 8-bit PNG use this function, I've just created function convertPNGto8bitPNG () function convertPNGto8bitPNG ($sourcePath, $destPath) { $srcimage = imagecreatefrompng($sourcePath); list($width, $height) = getimagesize($sourcePath); $img = imagecreatetruecolor($width, $height); $bga = imagecolorallocatealpha($img,

Detect the location of an image within a larger image

一笑奈何 提交于 2019-11-29 07:23:17
问题 How do you detect the location of an image within a larger image? I have an unmodified copy of the image. This image is then changed to an arbitrary resolution and placed randomly within a much larger image which is of an arbitrary size. No other transformations are conducted on the resulting image. Python code would be ideal, and it would probably require libgd. If you know of a good approach to this problem you'll get a +1. 回答1: There is a quick and dirty solution, and that's simply sliding

PHP+GD: imagecopymerge not retaining PNG transparencies

自古美人都是妖i 提交于 2019-11-29 04:45:57
I have two PNG files, "red.png" and "blue.png"; they are both mostly transparent, but there is a few pixels of red or blue splotches in various places. I want to make a PHP script that merges the two; it should be as simple as something like: $original = getPNG('red.png'); $overlay = getPNG('blue.png'); imagecopymerge($original, $overlay, 0,0, 0,0, imagesx($original), imagesy($original), 100); header('Content-Type: image/png'); imagepng($original); When I run this script, all I get is the blue dots -- with the transparency lost. I saw that I should add these: imagealphablending($original,

Find JPEG resolution with PHP

半腔热情 提交于 2019-11-28 19:58:43
Calling all PHP gurus! I understand that you can use getimagesize() to get the actual pixel height and width of an image in PHP. However, if you open an image in photoshop and look at the image size dialog, you notice that there is a resolution value that determines the print size of the image. Given an arbitrary jpg image file, I need to use PHP to determine this resolution number. It appears that this information is stored in the jpg file somewhere, so how do I get to it? One other requirement - I only have gdlib available to me. I need to do this without the use of other php libraries