Page 1 of 1

htm to jpeg setup?

Posted: 2016-10-11T10:47:06-07:00
by pctechtv
I am trying to understand the way to get html2ps set up to convert an htm page to jpeg. I have downloaded and installed a Perl package, and I have the html2ps folder unzipped. It seems like the instruction just say, open the html2ps.html file in a browser. Could someone explain more how to set this up, so ImageMagick has what it needs to do this type of conversion. Thanks

Re: htm to jpeg setup?

Posted: 2016-10-11T11:18:30-07:00
by fmw42

Re: htm to jpeg setup?

Posted: 2016-10-12T11:53:50-07:00
by pctechtv
Hi, I got it working. I think... what is produced in the ps file is only text based. I know a little about post script from my printing days and this makes sense. I am only going to see that type of output?... correct? I was misleading myself thinking that I would see an screenshot of the html page. Is there anyway to produce more of a screenshot? Thanks

Re: htm to jpeg setup?

Posted: 2016-10-12T12:12:03-07:00
by Bonzo
I have not tried this lately but it used to work for me:

Code: Select all

<?php
// Need to modify the crop width to remove a vertical scroll bar if its in the image !
$url = array( 'site1.info', 'site2.com', 'site3.com', 'site4.co.uk', 'site5.info');

foreach( $url as $value ){
	
$site = "http://www.".$value;

$browser = new COM("InternetExplorer.Application");
$handle = $browser->HWND;
$browser->Visible = true;
$browser->Navigate("$site");
// Still working?
while ($browser->Busy) {com_message_pump(4000);
}$im = imagegrabwindow($handle, 0);
$browser->Quit();
imagepng($im, "temp.png");
imagedestroy($im);

// Crop browser window, resize and save image
$width = '1180';
$height = '872';
$x_offset = '10';
$y_offset = '157';
$qulity = '100';

exec("convert temp.png -crop {$width}x{$height}+{$x_offset}+{$y_offset} -resize x200 $qulity $value.jpg");
	echo "<img src=\"$value.jpg\">";
}
?>  
The result depends on what the site is like. In my code I do a crop but some sites have side bars and the page may go below the "fold". From memory animations gave some problems as well.

Re: htm to jpeg setup?

Posted: 2016-10-12T14:53:06-07:00
by snibgo
Is there anyway to produce more of a screenshot?
To get a raster image of a web page (local or URL), http://wkhtmltopdf.org/downloads.html seems to do the job without fuss.

You can specify the height you want (to get just the top "screenfull") or no height to get the entire page.

You can make a delegate.xml entry to use it from within IM. This works fine when the web page is local, but I haven't figured how to make it work from the internet. We can just wget the page first, of course.

Re: htm to jpeg setup?

Posted: 2016-10-12T15:15:02-07:00
by pctechtv
Thanks guys really great and considerate. I hope I can make good contributions to this great forum once I learn more about ImageMagick. @Bonzo Thank you, what is good is that PHP is a language I am very proficient with. @snibgo I am checking out it looks really cool. Your advice is super helpful. @fmw42 thank you as well. Thanks