How to put an image url from internet in tcpdf file? - php

Hi I want to put an image into the PDF file I'm making using TCPDF. It is an image generated by an online API so I cannot store it on my webhost. But when I put the image URL for creating I'm getting error while generating the PDF file.

TCPDF can only use images saved on your webhost - local files, as it needs a physical path to the image in order to include it in the document. The only way you could grab an image from HTTP to be used for TCPDF would be to use cURL, which is something I have only used for text and html, but have no experience grabbing images with, but I'm sure there's a way it can be done.

Related

Dynamically Resize Images with PHP and Protect them from Direct Original Size Access

Think stock images. You have a full-size original that can only be downloaded after purchase. You only want to have that image once on your server, at full-size. But you want to display that image in various places in smaller sizes (responsively reduced for mobile devices as well).
I've got various pieces of this puzzle, but have not been able to make them all work together:
With TimThumb or CImage I can resize the images server-side, and using jQuery I can dynamically change the image source based on the user's screen size.
With PHP and .htaccess I can place the image files outside of the webroot and route a spoof URL containing image name to the PHP file that will read the actual image and send a header with the image data. Fine.
But TimThumb and CImage work with the real image URLs and they test to make sure that the given URL is the actual file path of the image.
If I could send the actual image data to the image resizing script rather than the URL to the image, it should work out from there. Since the PHP script would be reading the image data, I could check to see that the user has been given the proper credentials before doing the read.
Are there any other solutions you can think of besides hacking TimThumb or CImage or writing my own custom image resizing script?
Thank you
The answer just came to me.
With .htaccess, route all images through the image processing script. On the first line of the image processing script I will include my own custom script. My custom script will check the GET parameters against the actual image to determine if the user has the credentials to be served the image being requested at the size it is being requested.
If so, let the image processing script continue, if not, exit out or change the GET parameters to that the image processing script serves a placeholder image.
VoilĂ !

How to modify layers of static swf file (image) and create its preview in php

I would like to know, how to work with SWF images in PHP. My SWF image has some layers and I need to modify their opacity and colors if it is possible.
I also need to generate some type (jpg,png,...) of image preview.
I found something about Ming library, but I read It is not possible to create image preview using it and I can not understand how to modify my swf file.
SWF isn't an image file, it is a published Flash file that isn't editable. Even if you import it into Adobe Flash you still won't have access to all of the assets it contains.
http://en.wikipedia.org/wiki/SWF

PHP Image uploading

I have a working script for image uploading that is storing image data in binary format into mysql and when retrieving i am using header(content-type...).Is there any way to add some text contents to the page where the http header is going.
Short Answer: No
If you send an image via Content-Type then the browser expects the Content-Type. But you can dynamically add text to the image with the GD or Image Magick library. Nevertheless it is not very performant to store images in mysql.
I think a better solution would be to store all the images in a directory, and create a page that shows the selected image + the text you want to add. So output that page as HTML, not as an image (so not setting Content-Type to image).
Better save the images in a folder, in database just store their location.
Try the imagecreatefromstring() method, documentation available in http://in2.php.net/imagecreatefromstring.

Is there a way to take a snap shot of a uploaded file ex PDF, DOCX and save it to server as an image in PHP?

I have a form and that allows you to upload your resume with a pdf, docx ext. I would like to save their ip as an image and turn their uploaded file also into an image and send the images to hr in email.
Any suggestions on how to best get this done? All with PHP
The PDF part is easy using PHP and ImageMagick.
I am not aware of anything that creates images from DOCXs.
Out of interest, why would you want to send HR the images rather than the original documents?

ckeditor, php, image display issue

I have a download.php file to display images on a web page as well as downloading files like pdfs, docs, etc.
in ckeditor if the src for the image is /download.php it dispalys like there is no image or broken link image, if the src for the image is http://www.mydomain.com/download.php my image displays just fine in ckeditor.
Any thoughts? And no i cant just make it put the full domain. There is a reason to long, complicated, and stupid to explain thanks to the web hosting company.
In the configuration you need to set the baseHref to the full path, then it will add that to the images/files you upload and insert.

Categories