gd

Ways to stop people from uploading GIFs with injections in them?

蓝咒 提交于 2019-12-03 05:04:08
问题 I have a PHP website where people can fill out help-tickets. It allows them to upload screenshots for their ticket. I allow gif, psd, bmp, jpg, png, tif to be uploaded. Upon receiving the upload, the PHP script ignores the file extension. It identifies the filetype using only the MIME information, which for these filetypes is always stored within the first 12 bytes of the file. Someone uploaded several GIFs, which when viewed with a browser, the browser said it was invalid, and my virus

Merge a png ontop of a jpg and retain transparency with php

血红的双手。 提交于 2019-12-03 03:41:15
I have a PNG and I'm trying to merge it on top of a JPG. With the following code $dest = imagecreatefromjpeg("example.jpg"); $src = imagecreatefrompng("example.png"); imagealphablending($dest, false); imagesavealpha($dest, true); imagealphablending($src, true); imagecopymerge($dest, $src, $src2x, $src2y, 0, 0, $src2w, $src2h, 100); header('Content-Type: image/png'); imagepng($dest, "user/".$imei."/".$picCount."_m"); imagedestroy($dest); imagedestroy($src); Results in the following I also tried a suggestion from a similar question which said to use 'imagecopyresampled' isntead of

How to create GD Image from base64 encoded jpeg?

妖精的绣舞 提交于 2019-12-03 03:11:08
I have an upload Api that as a response object delivers (along with other stuff inside a Json object) a base64 encoded jpeg image. I create the encoded image as so: $im; // gd image resource ob_start(); imagejpeg($im); $data = base64_encode(ob_get_clean()); The data then is put inside a form field using javascript and submitted. How can I create a GD resource from that again so that I actually can save that image as a file? Everything in PHP. You can use imagecreatefromstring() function: $data = base64_decode($_POST['image_as_base64']); $formImage = imagecreatefromstring($data); "String" does

CentOS: Enabling GD Support in PHP Installation

限于喜欢 提交于 2019-12-03 01:28:43
问题 How do I go about enabling GD Support in a CentOS Installation? 回答1: The thing that did the trick for me eventually was: yum install gd gd-devel php-gd and then restart apache: service httpd restart 回答2: You need to find a repo that offers a GD lib matching your current php version. I've had great success using Remi Collet's repo for this purpose. In fact, I used it yesterday to update my php install to the latest 5.4.0RC6 version on my CentOS6 box. Once you've setup the repo it's a simple

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;

ImageMagick vs GD - which is faster, less resource intensive and produces better images?

隐身守侯 提交于 2019-12-02 23:27:36
I need to choose between either ImageMagick or GD library for the following image manipulation tasks: resizing images into multiple sizes watermarking images As you can see I don't need anything fancy. I'm sure both these tools can achieve them, so if one has more extra features than the other, I don't really care about. My main concern is performance and quality. Which of these 2 tools consumes less resources, is faster and produces better quality images? P.S. I need to use it with their respective PHP APIs. I would lean towards ImageMagick as far as image quality goes. It seems to produce

Compiling PHP with GD and libjpeg support

坚强是说给别人听的谎言 提交于 2019-12-02 22:30:35
I compile my own PHP, partly to learn more about how PHP is put together, and partly because I'm always finding I need modules that aren't available by default, and this way I have control over that. My problem is that I can't get JPEG support in PHP. Using CentOS 5.6. Here are my configuration options when compiling PHP 5.3.8 : './configure' '--enable-fpm' '--enable-mbstring' '--with-mysql' '--with-mysqli' '--with-gd' '--with-curl' '--with-mcrypt' '--with-zlib' '--with-pear' '--with-gmp' '--with-xsl' '--enable-zip' '--disable-fileinfo' '--with-jpeg-dir=/usr/lib/' The ./configure output says:

Install GD library and freetype on Linux

独自空忆成欢 提交于 2019-12-02 20:10:11
I'm trying to use imagefttext. And I need to have GD library and/or freetype installed. I'm new to this kind of stuffs, How can I install GD library and freetype in Linux ? Installing GD : For CentOS / RedHat / Fedora : sudo yum install php-gd For Debian/ubuntu : sudo apt-get install php5-gd Installing freetype : For CentOS / RedHat / Fedora : sudo yum install freetype* For Debian/ubuntu : sudo apt-get install freetype* Don't forget to restart apache after that (if you are using apache): CentOS / RedHat / Fedora : sudo /etc/init.d/httpd restart Or sudo service httpd restart Debian/ubuntu :

Ways to stop people from uploading GIFs with injections in them?

别说谁变了你拦得住时间么 提交于 2019-12-02 19:22:36
I have a PHP website where people can fill out help-tickets. It allows them to upload screenshots for their ticket. I allow gif, psd, bmp, jpg, png, tif to be uploaded. Upon receiving the upload, the PHP script ignores the file extension. It identifies the filetype using only the MIME information, which for these filetypes is always stored within the first 12 bytes of the file. Someone uploaded several GIFs, which when viewed with a browser, the browser said it was invalid, and my virus scanner alerted me that it was a injection (or something like that). See below for a zip file containing

php imagecopyresized vs imagecopyresampled vs imagecopy pros/cons

无人久伴 提交于 2019-12-02 18:42:46
These all seem to do the same thing. What are the pros/cons of each. imagecopyresized() vs imagecopyresampled() vs imagecopy(). I'm resizing a user submitted image. So I have an image shell created with '$newImage=imagecreatetruecolor(250, 250)'. And now I want to copy the orginal image into the '$newImage' Orangepill imagecopyresized will copy and scale and image. This uses a fairly primitive algorithm that tends to yield more pixelated results. imagecopyresampled will copy and scale and image, it uses a smoothing and pixel interpolating algorithm that will generally yield much better results