New extension: SnapshotPDF

Author Message

Felix Laate

Friday 20 January 2006 5:32:07 am

Hi all,

I just uploaded a new extension to http://ez.no/community/contribs/template_plugins/snapshotpdf

It is similar to the Snapshot extension, only that this one grab a page of a pdf and returns a jpg.

If anyone has comments, they are apreciated here!

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Xavier Dutoit

Friday 20 January 2006 1:29:27 pm

Hi,

Would this extension be possible to use to populate an image attribute ?

My idea is to add an attribute image to the class file, and automatically populate it with the snapshot of the first page if the uploaded doc is a pdf.

Does it make sense ?

X+

http://www.sydesy.com

Paul Borgermans

Friday 20 January 2006 2:43:35 pm

Hi Xavier

Nice work from Felix :-)

You could by creating a new datatype and re-use some of the coding from him. The trick is to use the post publish action of your new datatype to look up the file (which is another attribute of the object your new datatype belongs to) and create the snapshot. Also implement the has_content property.

In the view template of such a class, use the has_content property to display the snapshot if its available.

Feasible, but requires some coding I'm sure you will be able to do :-)

Regards

--paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Xavier Dutoit

Saturday 21 January 2006 12:46:48 pm

Hi Paul,

didn't realise you have a blog. Is that new ?

X+

http://www.sydesy.com

Paul Borgermans

Sunday 22 January 2006 4:29:23 am

Hi Xavier,

Yes the blog is rather new ...

Cheers

--paul

eZ Publish, eZ Find, Solr expert consulting and training
http://twitter.com/paulborgermans

Petter Arneson

Thursday 26 January 2006 7:52:18 am

Hi!

Nice extension!

I'm trying to make a thumbnail of pdf's using this extension.
Using css to set image size seems like a bad solution, so I had a look at Ghostscript commands to be able to utilize width, height and resolution parameter.

http://www.cs.wisc.edu/~ghost/doc/AFPL/7.04/Use.htm#Parameter_switches

It seems to be parameters like -dDEVICEWIDTHPOINTS=w and -dDEVICEHEIGHTPOINTS=h, but I cant get it to work, the size stays the same.

Template:

<img src="{ezsnapshotpdf($node.object.data_map.file.content.filepath,2,100,150)}" alt=""/>

Extension:

$command = 'gs -dNOPAUSE -dBATCH -dFirstPage=' . $page . ' -dLastPage=' . $page;
$command = $command . ' -dDEVICEWIDTHPOINTS= ' . $width . ' -dDEVICEHEIGHTPOINTS=' . $height;
$command = $command . ' -sDEVICE=jpeg -sOutputFile= ' . $save_file . ' -r72 -c --setpdfwrite ' . $file;

Felix, do you have any tips?

www.vzt.no

Felix Laate

Thursday 26 January 2006 1:01:30 pm

Hi Petter,

I just released a new version (0.2) of the extension that has resizeing abibilties. Hope it is what you needed.

Have a look at: http://ez.no/community/contribs/template_plugins/snapshotpdf

Cheers and beers

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Petter Arneson

Friday 27 January 2006 2:49:27 am

Excellent!!

Just what I needed, good work.

I want to show the thumbnail in a line view, with a link to full view.
It seems I have to trick it a bit to get the thumbnail filename, and the page has to be refreshed to show the thumbnail picture.

This is what I got in the lineview template:

	{section show=eq($node.object.data_map.file.content.mime_type_part,'pdf')}
		<div class="attribute-short">
			<p><b>Ezsnapshotpdf Thumbnail</b></p>
			{def $fullpath = ezsnapshotpdf($node.object.data_map.file.content.filepath,1,$height,$width)}
			{def $split = $fullpath|explode('.')}
			{def $thumbpath = concat($split.0,'.',$split.1,'-',$height,'x',$width,'.',$split.2)}
			<img src="{$thumbpath}" alt=""/>
		</div>	
		<div class="attribute-short">
			  <a href={ezsnapshotpdf($node.object.data_map.file.content.filepath,1)}>See PDF full view</a>
		</div>
	{/section}

www.vzt.no

Felix Laate

Saturday 28 January 2006 4:49:09 am

Hi Petter,

if it's ok with you, I'll add your code snippet as an example of usage to the readme-file.

Felix

Publlic Relations Manager
Greater Stavanger
www.greaterstavanger.com

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 18 2025 21:14:30
Script start
Timing: Jan 18 2025 21:14:30
Module start 'layout'
Timing: Jan 18 2025 21:14:30
Module start 'content'
Timing: Jan 18 2025 21:14:31
Module end 'content'
Timing: Jan 18 2025 21:14:31
Script end

Main resources:

Total runtime1.1300 sec
Peak memory usage4,096.0000 KB
Database Queries79

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0049 587.9141152.6250
Module start 'layout' 0.00490.0029 740.539139.4453
Module start 'content' 0.00781.1207 779.9844692.3125
Module end 'content' 1.12850.0015 1,472.296920.1641
Script end 1.1299  1,492.4609 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00320.2858160.0002
Check MTime0.00130.1160160.0001
Mysql Total
Database connection0.00060.053410.0006
Mysqli_queries1.049792.8969790.0133
Looping result0.00080.0728770.0000
Template Total1.099297.320.5496
Template load0.00200.181120.0010
Template processing1.097197.093820.5486
Template load and register function0.00010.008510.0001
states
state_id_array0.00120.110010.0012
state_identifier_array0.00170.149220.0008
Override
Cache load0.00180.1630670.0000
Sytem overhead
Fetch class attribute can translate value0.00130.111940.0003
Fetch class attribute name0.00200.1741120.0002
XML
Image XML parsing0.00180.162140.0005
class_abstraction
Instantiating content class attribute0.00000.0029160.0000
General
dbfile0.00110.0998290.0000
String conversion0.00000.000940.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
7content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
9content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
13content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
3content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 36
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs