php-gd

Troubles with Docker + PHP7 + GD resulting in “Call to undefined function imagecreatefromjpeg()”

流过昼夜 提交于 2019-12-04 08:29:54
问题 I'm having troubles when trying to create an image using imagecreatefromjpeg using this Dockerfile to generate the container: FROM php:7.1-apache RUN apt-get update && \ apt-get install -y -qq git \ libjpeg62-turbo-dev \ apt-transport-https \ libfreetype6-dev \ libmcrypt-dev \ libpng12-dev \ libssl-dev \ zip unzip \ nodejs \ npm \ wget \ vim RUN pecl install redis && docker-php-ext-enable redis RUN docker-php-ext-install -j$(nproc) iconv mcrypt zip pdo pdo_mysql gd bcmath COPY ./containers

PHP: Determine Visually Corrupted Images (yet valid) downloaded via Curl with GD/Imagemagick

穿精又带淫゛_ 提交于 2019-12-03 17:54:03
问题 I'm using Curl via Proxies to download images with a scraper I have developed. Unfortunately, it gets the odd image which looks like these and the last one is completely blank :/ When I test the images via imagemagick (using identify) it tells me they are valid images. When I test the images via exif_imagetype() and imagecreatefromjpeg() again, both these functions tell me the images are valid. Does anyone have a way to determine if the image has majority of greyness or is completely blank

Troubles with Docker + PHP7 + GD resulting in “Call to undefined function imagecreatefromjpeg()”

耗尽温柔 提交于 2019-12-02 23:47:08
I'm having troubles when trying to create an image using imagecreatefromjpeg using this Dockerfile to generate the container: FROM php:7.1-apache RUN apt-get update && \ apt-get install -y -qq git \ libjpeg62-turbo-dev \ apt-transport-https \ libfreetype6-dev \ libmcrypt-dev \ libpng12-dev \ libssl-dev \ zip unzip \ nodejs \ npm \ wget \ vim RUN pecl install redis && docker-php-ext-enable redis RUN docker-php-ext-install -j$(nproc) iconv mcrypt zip pdo pdo_mysql gd bcmath COPY ./containers/yii.conf /etc/apache2/sites-available/000-default.conf RUN for mod in rewrite headers; do a2enmod $mod;

single pixel manipulation with php GD

╄→尐↘猪︶ㄣ 提交于 2019-12-02 08:01:48
问题 First I'm referring to a previous question Change image per pixel and save to db I found that the html5 canvas isn't suitable because it's hard to keep the source-image secret. That's why I'm trying to achieve my goal with the PHP GD library. I never worked with this library so I have some difficulties. I guess I need the following functions imagecreatetruecolor for creating the image in the browser imagecolorallocate for returning rgb from source-image imagesetpixel for drawing the random

PHP recursive function return value

情到浓时终转凉″ 提交于 2019-11-30 13:02:09
I have written a recursive function in PHP to crop text. The cropped text will have ... attached to the end. Non-cropped text will be returned in its original state. It works if the text fits the max width. However, if it does not fit in the given width the function will not return a value but it should. It seems that the whole return statement is ignored. If I replace the return with echo, it shows the correct value. The expected result: -TEST ZIN -TEST ZI -TEST Z -TEST -TES -TE... (nothing is returned here so this will never be shown) function check_length($str, $max, $size = SIZE, $rec =

After upgrade, PHP no longer supports PNG operations

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-29 20:00:45
After updating to Mac OS X 10.10 (Yosemite) and starting Apache with PHP support, everything works as before except for any image operations on PNG files. I get a Call to undefined function imagecreatefrompng() , while any operation on JPEG files work. So GD is present, but not for PNG. There is one line in the phpinfo() that looks like the problem: '--with-png-dir=no' The GD section from phpinfo() : How do I get the included PHP to work with PNG files? Here's another option, from the guys from liip, here . This is a PHP package that comes pre-built for Yosemite (older versions works too) but

PHP recursive function return value

≯℡__Kan透↙ 提交于 2019-11-29 18:43:33
问题 I have written a recursive function in PHP to crop text. The cropped text will have ... attached to the end. Non-cropped text will be returned in its original state. It works if the text fits the max width. However, if it does not fit in the given width the function will not return a value but it should. It seems that the whole return statement is ignored. If I replace the return with echo, it shows the correct value. The expected result: -TEST ZIN -TEST ZI -TEST Z -TEST -TES -TE... (nothing

Transparent PNG over JPG in PHP

佐手、 提交于 2019-11-29 14:33:38
What seems to be simple, isn't :( I'm trying to add something like a watermark (transparent png) on an image (jpg). This is the code I'm using: $width = 800; $height = 600; $bottom_image = imagecreatefromjpeg("portrait1.jpg"); $top_image = imagecreatefrompng("man2.png"); imagesavealpha($top_image, true); imagealphablending($top_image, true); imagecopy($bottom_image, $top_image, 200, 200, 0, 0, $width, $height); header('Content-type: image/png'); imagepng($bottom_image); When I merge the images, the png is positioned at the right place, everythig above and left of it is good (jpg is copied),

how to draw semi-transparent rectangle in php?

…衆ロ難τιáo~ 提交于 2019-11-29 02:21:11
Here is an example what I would like to do: Here is the result: function red_rectangle($img_src,$x1,$y1,$x2,$y2,$tr = 50) { // Load image $img = imagecreatefromjpeg($img_src); // Transparent red $red = imagecolorallocatealpha($img, 255, 0, 0, $tr); // Draw a white rectangle imagefilledrectangle($img, $x1, $y1, $x2, $y2, $red); // Save the image (overwrite) imagejpeg($img, $img_src); imagedestroy($img); } You need to use http://php.net/manual/en/function.imagefilledrectangle.php , passing a color created with http://www.php.net/manual/en/function.imagecolorallocatealpha.php . As you can see,

After upgrade, PHP no longer supports PNG operations

↘锁芯ラ 提交于 2019-11-28 15:52:35
问题 After updating to Mac OS X 10.10 (Yosemite) and starting Apache with PHP support, everything works as before except for any image operations on PNG files. I get a Call to undefined function imagecreatefrompng() , while any operation on JPEG files work. So GD is present, but not for PNG. There is one line in the phpinfo() that looks like the problem: '--with-png-dir=no' The GD section from phpinfo() : How do I get the included PHP to work with PNG files? 回答1: Here's another option, from the