Image gets distorted along the edges after using imagerotate function - php

I am using imagerotate() function to rotate the images according to the orientation.
The following image is rotated via $realignedImage=imagerotate($temp,-90,0);
This is the result of the rotation

Related

How to add watermark Image using MPDF in codeigniter

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
);

Font color not change in php intervention image manipulation

I'm using PHP Intervention Image Library 2.x to put some text on an image. Everything works fine except for the font colour.
Font size, font, font angle, and the position change according to the given values, the only issue is it not takes the colour I'm setting in the callback function.
Image::configure(array('driver' => 'imagick'));
$img = Image::make(IMG . 'gold-full.jpg');
$font = new Intervention\Image\Imagick\Font();
$img->text('Y. C. Perera', 1061, 1298.4, function($font) {
$font->file('./img/ERASBD.TTF');
$font->size(88);
//$font->color('#fff');
//$font->color('white');
//$font->color(array(255,255,255));
$font->color('#ffffff');
});
$img->save('./uploads/new-gold-full.jpg');
$img->destroy();
As I mentioned with the comment I tried all those types of settings for the color. but no luck.

png with transparency and png-derived blob are rendering black on canvas element instead of transparent

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.

CROP IMAGE IN FPDF is possible?

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');

Rotate an image in clockwise & Anti Clockwise direction

I have used http://raphaeljs.com/image-rotation.html raphel's script but. How how can v save this rotated image.
It's an SVG, not really an image per-se.
You'll have to save the generated SVG via AJAX onto your server and render it with an external SVG-rendering library.
You could try librsvg2-bin, as I've heard that it works.
As mentioned it's an SVG element and it uses a source image to change it's angle upon clicking the rotate buttons. By inspecting the rotated image you'll see the SVG element like:
<image x="160" y="120" width="320" height="240" preserveAspectRatio="none" href="http://raphaeljs.com/bd.jpg" transform="rotate(-90, 320, 240)"/>
You'll notice that there's a tranform attribute that contains the rotate(angle, x, y) function. If you can find a way to get that angle value you can use it to manipulate the image source to generate a new image using PHP by using the imagerotate function.
By doing this I got the transform attribute value:
document.getElementById('holder').getElementsByTagName('image')[0].getAttribute('transform')
This returns "rotate(-90, 320, 240)"
Of course this is a hack ;p

Categories