Having issue with converting image to PDF in Opera Browser

Questions and postings pertaining to the development of ImageMagick, feature enhancements, and ImageMagick internals. ImageMagick source code and algorithms are discussed here. Usage questions which are too arcane for the normal user list should also be posted here.
Locked
rp.narola
Posts: 1
Joined: 2019-11-25T05:29:10-07:00
Authentication code: 1152

Having issue with converting image to PDF in Opera Browser

Post by rp.narola »

Hi,

I am using ImageMagick for converting image to PDF. It's working with most of the browser except Opera. Version of Opera is 65.0.3467.48.

What we are trying to achive is :

1. converting PDF to Image then
2. Adding watermark to image then
3. Reconverting the image to PDF again

The result what we are getting at the final is converted PDF are in grayscale. It's not mantaining the color combination of orignal image.

We are facing this issue spcific to Opera browser and Google chrome on random bases.

Below is the code which we are using to convert IMAGE to PDF.

Code: Select all

$img = new Imagick();
$pdf = $filename;
$saveAsPath = '#Destimation Path for storing the image';
$img->setResolution(400, 400);
$img->readImage('#SourcePDFLocation');
$num_pages = $img->getNumberImages();
$img->setImageCompressionQuality(70);
$pdf_images = array();
for ($i = 0; $i < $num_pages; $i++) {
    $img->setIteratorIndex($i);
    $img->setImageFormat('jpg');
                        $img->stripImage();
    $image_name = "image_".$subscriber_id.".jpg";
    $pdf_images[] = $saveAsPath.$image_name; 
    $img->writeImage($saveAsPath.$image_name);
}
$img->destroy();

$image = new Imagick($saveAsPath.$image_name);

$watermark = new Imagick();


$text = 'Watermark Text';
$draw = new ImagickDraw();
$watermark->newImage(4090, 4200, new ImagickPixel('none'));

$draw->setResolution(400, 400);
$draw->setFontSize(16);
$draw->setFillColor('black');
$draw->setFillOpacity(.3);

$position = 1000;
for($i= 1 ; $i<=5; $i++)
{
    $watermark->annotateImage($draw, 10, $position, -15, $text);

    $position = $position + 800;
}
$image->compositeImage($watermark, Imagick::COMPOSITE_OVER, 150, 80);

$image->setImageFormat('jpg');
$image->writeImage($saveAsPath.$image_name);
exec("convert -antialias #SourceImageName #NewPDF.pdf");
Looking forward to your response.

Thanks,

snibgo
Posts: 13034
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Having issue with converting image to PDF in Opera Browser

Post by snibgo »

rp.narola wrote:We are facing this issue spcific to Opera browser and Google chrome on random bases.
If your PDFs show correctly in Adobe Acrobat Reader, then I suggest you raise the problem with Opera and Google.
snibgo's IM pages: im.snibgo.com

Locked