May i crop images in FPDF ?
i have try this one Cropping images in CodeIgniter for FPDF output but does not work
You can use clipping areas: http://www.fpdf.org/en/script/script78.php
With this extension you can define your visible area and output your image like this:
$pdf->ClippingRect($x, $y, $w, $h);
$pdf->Image($imageFile, $x - $imgOffsetX, $y - $imgOffsetY);
$pdf->UnsetClipping();
The whole image will be included in the pdf. If size matters, cropping the image file first can be the better way.
Sorry, you can not crop an image in FPDF. You must first crop the image before using it to create a PDF using FPDF. I can recommend doing this manually, or programmatically via ImageMagick. Then once you have your cropped jpg, gif or png, call Image.
$pdf->Image('croppedImage.png');
Related
I have a problem when opening with Illustrator a PDF generated with TCPDF that embeds a CMYK image (jpg).
The PDF looks just fine when opening it on a web browser or with Acrobat Reader.
But when trying to open it with Illustrator : although, the file is under the expected CMYK color mode, the rendered colors are not correct at all and looks "mainly black".
Basically :
I create and export a simple CMYK JPG image with Illustrator (see image)
NB : embedding the color profile or not doesn't change the result.
I create the PDF and insert the CMYK jpg image using TCPDF :
$this->pdf->Image("image.jpg", $x, $y, $w, $h, '', '', '', false, $dpi);
The result looks nice on a web browser or in Acrobat Reader : image
But the render is completely wrong when opening the PDF with Illustrator : image of bad render
I have tried the two ways suggested here :
https://github.com/tecnickcom/TCPDF/issues/192
But nothing is working.
I would like to open the PDF with Illustrator to be able to make some manual changes in some cases.
Has anyone a clue about this ?
here is the pdf image
I want to add this kind of background image to my PDF using MPDF. But also i want to reduce the background image opacity.
Try this-
$mpdf->SetWatermarkImage(
'assets/dist/img/ExampleLogo1.png',
0.3, // this for transparency
array(x,y), // Alignment
);
I am letting users preview images using URL.createObjectURL() (which represents the image as a blob). This has worked great, but now I am using the plugin jCrop to let users crop said images and I have encountered a minor issue.
jCrop has worked fine for blobs derived from jpg files and png files w/o transparency, but blobs derived from png files with transparency are rendering transparent pixels (on the canvas) as black (the same effect was happening with these images when resized and uploaded to the backend (php) but this was corrected using imagealphablending()).
jCrop is called as followed:
jQuery(function($) {
$("#myImageContainer").Jcrop({
onChange: myFunction
}, function () {
jcrop_api = this;
});
});
The "black" images on canvas are uploaded and saved properly with transparency, so this is a front end effect only. Additionally, the same effect is observed when the source png is used to preview instead of the png-derived blob. Is their any way to correct for this effect on the canvas instead of the backend?
UPDATE: The transparent image is black from the start...I am assuming the author of the plugin set the canvas background to be black. I will try and change this.
Before I explain, you may want to take a quick look at my thumbnail generation code: http://pastebin.com/XAPPcUyZ
I pass several image types through this script: jpeg,jpg,gif,png
All types create a 220px wide thumbnail like they should, the problem arrises when the script runs into an animated .gif image - when attempting to make a thumbnail for the gif it outputs something like this: http://i.imgur.com/oh50z.gif where the image appears tiled when a proper thumbnail should look more like this: http://whatimg.com/i/mhsnf4_thumb.gif.
If I remove 'interlace -line' the animated gif's generate thumbnails without any issue, however I would like to leave this in so that the other file formats are interlaced for faster loading. Is there a way to run interlace without breaking animated gifs like this? If there isn't how can I go about detecting if a gif is animated and running a non-interlaced convert on it instead?
There are images displayed inside a HTML table in a PHP code :
The code of this table is :
for ($i = 0; $i < $data['list']['cnt']; $i++) {
$tabRows[$i][1]['width'] = "45%";
$tabRows[$i][1]['align'] = "center";
$tabRows[$i][1]['value'] = '<img src="'.HTTP_FIGURES.$data['list'][$i]['fig_image'].'" />';
}
As you can see the background of the images are seen and they make the page dirty. So I want to remove the background of each image. How to do that ?
Make the images a transparent PNG.
Your only practical solution is to go through each image with an image editor, delete the background and re-save as a .png with transparency.
Take any image editor like GIMP (free), Paint.net(free), Photoshop or any other image editor and add transparency where you need it. Here is a tutorial for paint.net. If your images are not in PNG - you will need to make PNG images as JPEG has no transparency.
You have 2 options:
Edit images with a image editor like paint.net and make the backgrounds transparent.
Use the PHP GD functions to 'edit' the images. This can be cumbersome, because you have to determine what color you want to replace with a background color. Often, a fixed color is used, or the color in pixel[1,1].
My advise, if there are not to many images, go for 1.