I am trying to copy an image from a remote URL, but some urls have dynamic images, for example:
https://www.webgains.com/image.html?file=program/logo/117.jpg
This is not a static image and is dynamically generated using a script of some sort.
When I try to use PHPs copy() or file_put_contents() to copy the image to my server, it just generates a 1x1 pixel image.
What can I do to get the image saved properly?
Related
I created an image class, it loads and resizes image, then crops and lastly watermarks it.
For last step, I would like to add IPTC data to the this image. For what I know there is only iptcembed function to accomplish this. The problem is iptcembed needs the path of image as parameter. I'm keeping image as object before using it to render views.
$content = iptcembed($data, "./image.jpg");
I do not want to save image to storage just to create a path for iptcembed but I couldn't find another way to add IPTC data to the image.
Is there any way (or function) to access to this object from memory instead of saving and loading from storage?
You could use php://memory to have a file handle that reference in-memory data instead of data written to a file.
Credit goes to this original answer
I use CFX_OpenImage to read and write IPTC_ data in .jpg files using ColdFusion Language versions 8 thru 11. I also use CFX_OpenImage for image resize and rotation.
For more CFX_OPENIMAGE INFO go to http://www.kolumbus.fi/jukka.manner/cfx_openimage/
The software download includes a good manual of at least 65 pages.
We're working on a script that draws multiple images on a canvas, after manipulating each of them separately, i.e. resize + rotate.
The canvas is an image resource, which we need to copy the manipulated images to. In order to achieve this, my only thought is using PHP's imagecopy function, which requires that the image being copied be a resource too. So, how can I obtain the manipulated image from image_lib as a resource?
There is no reason why you shouldn't use imagecopy to accomplish this. The image library in CodeIgniter isn't really set up for what you're trying to do so you'll have to extend it's functionality yourself.
Is it possible to add php image resize code to my coldfusion page? Images look significantly sharper when resized by php instead of coldfusion(even when I use the coldfusion's imageResize "highestquality" option).
<cfftp action="PUTFILE"
server="#ATTRIBUTES.FtpServer#"
username="#ATTRIBUTES.FtpUsername#"
password="#ATTRIBUTES.FtpPassword#"
stoponerror="No"
localfile="#ATTRIBUTES.LOCALIMAGEFILE#"
remotefile="#Filename_Temp#"
transfermode="BINARY"
connection="DOCMGR"
retrycount="1"
timeout="60"
passive="Yes">
<!-- Add php resize image code here -->
If you can run PHP and ColdFusion on the same server, upload using CF and store the file in a common location.
Cfhttp GET a separate PHP page which resizes the image to your specifications.
Then the caller CF page would do what it needs to with the image.
If you cant get PHP and CF on the same server, you could always cfhttp POST the image to the other server. Make sure you use a multi-part form post, otherwise you'll lose data on images >~ 1mb.
If you're ftping the file from CF to another server, you could http post the image to PHP which could resize then ftp the new image for you without having to send it back to CF first.
The other option is calling imagemagick directly using the command line, ie. cfexecute.
You'll get better performance calling imagemagick directly, rather than having php pass on the request. Unless of course, you want to use php to programatically alter the images. You should be able to achieve the same results with well crafted command line calls though.
I'm creating a web app that allows users to specify an image url to display an image along with their submission.
To avoid some potentially large images and odd sizes, i'd like to use PHP to limit/resize the image before it gets output to the browser (I know i could use max-width in CSS but this is unnecessary downloading)
Is this possible?
PHP has a library named GD. It's fairly easy to check the size of an image with the getimagesize() function.
You can find the complete code for it with 2 module/extensions: http://www.fliquidstudios.com/2009/05/07/resizing-images-in-php-with-gd-and-imagick/
a comparison of them can be found here: http://dreamfall.blogspot.com/2008/02/php-benchmarks-gd-vs-imagemagick.html which may be of use if you want optimize features.
I want to get remote images and resize them and store them as well as storing the original images.
I would like an option to regenerate images /thumbnails as well, so they are updated automatically.
The types of images that should be allowed are gif and jpeg
If possible then gif should also be converted to jpeg.
Anyone has simple class or function to do this?
Get remote images: curl or (assuming allow_url_fopen) simply fopen
Resize Images: gd or imagemagick