i have this message error:
Unsupported image type:imagePath was not found on this server.
I want to create pdf with jpg images taken from the iphone. Unfortunately this does not work. The image path is just seen that I can access it from my browser. When I change the way the path is erroneous.
A exemple of the code
$pdf->Image('../firstParthPath/'.$_SESSION['environment'].'/secondParthPath'.$ImageName,null,$heigth,40,50);
$ImageName are /image404-120404.jpg for exemple. I have tested variable name. It has /image404-120404.jpg
$heigth is a variable that is also handled automatically. It always has the desired content.
I tried to replace null with 0
I tried to add the option 'JPG'. Without success.
a exemple of image
http://imageshack.us/photo/my-images/72/image398120404.jpg/
It could be that PHP is not understanding the location via the relative path starting with '../'. You could try explicitly prepending the script path before it to make sure PHP is looking in the correct place:
(dirname(__FILE__) . '/../firstParthPath/'.$_SESSION['environment'].'/secondParthPath'.$ImageName,null,$heigth,40,50);
It's resolved. It was a verification error in the next picture. Now the problem's are resolved
Related
Am trying to download an image from remote server and save it in local folder but i cannot seem to find a solution here. i have seen a couple of similar questions around but mine is a bit unique.
Solutions here are for remote links ending in image name and extension e.g www.example.com/image.jpg mine is a plain url but links to an image whose image type and name is unknown e.g. https://example.com/images/6a9b0547-3d31-4dc9-891c-3ae6ec051056. please help.
Well, at first you have to download the file to a temporary place. Let's assume you save the file as 399443553.tmp. Use mime_content_type() function to get the mime type of the file. At last, move the file to its real location with the extension you got from mime_content_type()
Here is the documentation for mime_content_type()
Example from php.net
<?php
echo mime_content_type('php.gif') . "\n";
?>
output
image/gif
PS. Don't be confused about the .gif in the filename. It will return the real MIME type even if it is not there
Recently I have moved from my staging server to production server and I don't have access to any of these servers.
Both of these servers are linux.
On the new server while generating the pdf using mPDF with symfony 1.4 framework, images like rupee symbol are not getting displayed instead a small red "x" symbol is getting displayed in pdf.
Also, when I try to give background image to pdf, full image path like "http://example.com/image/rupee-image.jpg" is getting displayed instead of image.
Rupee symbol, other images and background images are working fine on my staging server.
When, I did $mpdf->showImageError(), It's saying "mPDF Image Error: Could not find image file" and pasting the url in browser displays the image perfectly.
Any help will be greatly appreciated.
mPDF is telling you that it's not finding the image.
Without seeing your code it's difficult to hint you on what's wrong.
Still you probably what to try referring to your images using a full path locally.
So instead of reference like http://example.com/image/rupee-image.jpg
use something like /var/www/mysite/image/rupee-image.jpg , same as if checking the image is there using the command line.
HTH
I had similar problem, i fixed it with replacing http:// to https://. Watch out for it.
I fixed it myself... I have created a variable in my template and then replaced that variable with image location from my action class, using $mpdf->WriteHTML(str_replace('rupee_symbol','₹',$html1));
My problem was PHP 7 in this case! I check condition
if (!empty('/images/someimg.png')) {
echo '<img ...';
} else {
echo 'error in PHP 7';
}
Be carefull using it. Version PHP 7.0.19
I'm currently trying out the TinyButStrong library with openTBS plugin to edit an OpenOffice writer template.
If I correctly understand, you can change a default picture to something else using this:
[b.number;ope=changepic;from='pic_[val].png';default=current;adjust]
I tried changing the from='pic_[val].png' to from='example.jpg', this didn't change the picture however.
Anyone knows how to get this working? Help will be greatly appreciated.
Put a fixed value in parameter "from" should force the image (it worked for me).
If your field has been merged (that is it does not appear in the result file) and you have no error message, then having the image unchanged means that the target file cannot be found.
I think the 'example.jpg' file should be placed in the folder with the script that manages TBS and OpenTBS. Otherwise, you have to specify a path.
You don't actually need to the 'from' parameter to just switch a picture out. OpenTBS gets the path of the picture from the first parameter - in your case b.number (which hopefully contains a path to an image). Adjust is also not required, unless you are resizing the picture.
[b.number;ope=changepic;default=current;]
Assuming:
$b->number = '/path/to/image.png'
Also keep in mind, if b.number is a block, you may need to define your block boundary for the data to populate. (If you are able to see the path in the $TBS->PlugIn(OPENTBS_DEBUG_XML_SHOW) mode don't worry about this) Try using [b.number] if you are not sure your data is being processed.
http://babymoments.co/preview/highres%20preview/5_357/
According to the FPDF documentation here: http://www.fpdf.org/en/doc/image.htm
You are supposed to be able to use an Image from a dynamic source.. however, as per the first link, i'm getting an fopen error.
Any suggestions?
Code Snippet:
// Overlay Text & Images
$pdf->Image($conf['rbase'].'page_maker/image_hr.php?id=5&side=1&bg=cover_pink&lo=0_1&imgtxt=0|0|u5_1310329746.jpg##1|1|Elina\'s Puppies 9/2/2010|15|arial_bi.ttf|db0ddb|fedfe4&applet_type=cover',$sx,$sh,(0-$dpi), 0, 'png');
You are trying to open a local php file with get parameters - try instead to open the image file as a url. For example :
http://domain.com/image.php?id=5
Or in your case...
http://babymoments.co/preview/page_maker/image_hr.php?id=5&side=1&bg=cover_pink&lo=0_1&imgtxt=0|0|u5_1310329746.jpg##1|1|Elina's%20Puppies%209/2/2010|15|arial_bi.ttf|db0ddb|fedfe4&applet_type=cover
I wouldn't fetch the preview over HTTP but would include the required code and generate the image in the same script that generates the PDF. That way there is no problems with setups that have disabled fopen()-usage with URLs.
I was implementing a barcode for a label printer. So I was using the 'barcodegen' library and 'fpdf' library for this project, but I was having problems including dynamically the image generated with barcodegen, giving me the following error:
FPDF error: Not a PNG file: ./misc/barcodegen/mostrar-codigo-bcgcode39.php
Afeter that, I use one of the answers described here, and I solved the problem using the full URL of the image, like this:
$pdf->Image("http://localhost/caaf/misc/barcodegen/mostrar-codigo-bcgcode39.php",0,0,20,0,'PNG');
And it worked for me.
I am using the FPDF library for generating PDF files by PHP. This library is working fine with plain text(i.e PDF files are generating for any text), but this is giving me an error of FPDF error: Missing or incorrect image file:{MY_FILE_PATH} while trying to add an image to my PDF page. Accessed that file path through the browser, then the corresponding image is appearing fine.
My code is:
require('fpdf.php');
$pdf = new FPDF();
$pdf->AddPage();
$pdf->SetFont('Arial', 'B', 16);
$pdf->Write(10, 'Example image');
$image_path = MY_FILE_PATH; // This variable contains my actual file path
$pdf->Image($image_path, 10, 10, 350, 450);
$pdf->Output();
This code is working perfectly in my localhost and generating the corresponding PDF files even with the images also, but this is not working after moving to the server.
I have tried with these possibilities like:
With absolute and relative paths for the image.
Tried with a local image placed in the same folder.
All image formats like jpg, png and gif also.
Checked the permissions for the image and corresponding folders also.
None of these cases are working for me, stuck with this problem, can anyone help me to slove this issue.
Thanks!
Siva ...
After a long struggle finally I found the reason for this issue which I've already discussed here.
Mainly this problem is due to the 'allow_url_fopen' setting which is not enabled for my server, I've solved this issue by using the CURL. I'm giving the step by step procedure to solve this issue because this may useful for somebody like me to avoid wastage of time(for finding the solution).
1. Create a temporary file in the local system with write permission.
Ex: $fp = #fopen($local_file_path, 'x');
fclose($fp);
2. Get the remote location file contents using CURL and write that to local file
which is created in the previous step.
Ex: $curl = new CurlWrapper($remote_file_path);
$curl->copyToFile($local_file_path);
3. Now send this local file path to FPDF function(image) then the corresponding
PDF will get generate for the file without any issues.
I think this is one method to solve this issue, if anybody knows some other ways then you can post them here so that this question may be useful for somebody.
just add:
allow_url_fopen = ON
on php.ini (create new if not exists) solves the problem.
http://www.solo-technology.com/blog/2010/04/07/quick-fix-for-url-file-access-is-disabled-issues/
anyone can use this code for solve. may be it will work. because sometime some case may be different. in my case i was getting same issue but after use it. i fixed my issue..
$pdf->Image($image_path, 10, 10, 350, 450 ,'');
try to give empty string to 6 parameter of $pdf->Image() function or you can give file extension like ( PNG or JPG). in my case empty string '' was working. because i was cropping image so that image going some time wrong. so after do that my problem gone fixed and i tested with different images.