f



perl module to convert a postscript image file to a jpeg/gif/xpm file

Hi,
Is there any perl module to convert a postscript file to a jpeg or gif
format. I create the postscript file from a canvas object which dumps
the display of the canvas to the postscript file. I thought of using
WinPhoto to save it in an xpm format but then again I did not know how
to save the non visible portions of the window into the xpm file. I
thought there might be some modules available for the conversion but
couldnt find any out there. Or if there is a way to save the canvas
image (both visible and invisible parts) to a suitable file then it
would be great for me to use.

Thanks for the help in advance.
Karthik
0
kars175
10/6/2004 1:22:58 AM
comp.lang.perl.tk 4721 articles. 0 followers. pharrendorf (19) is leader. Post Follow

6 Replies
878 Views

Similar Articles

[PageSpeed] 24

On 5 Oct 2004 18:22:58 -0700, kars175@yahoo.com (Karthik) wrote:

>Hi,
>Is there any perl module to convert a postscript file to a jpeg or gif
>format. I create the postscript file from a canvas object which dumps
>the display of the canvas to the postscript file. I thought of using
>WinPhoto to save it in an xpm format but then again I did not know how
>to save the non visible portions of the window into the xpm file.

What do you mean "non visible portions"?  WinPhoto should grab
a screenshot.

> I
>thought there might be some modules available for the conversion but
>couldnt find any out there. Or if there is a way to save the canvas
>image (both visible and invisible parts) to a suitable file then it
>would be great for me to use.
>
>Thanks for the help in advance.
>Karthik

-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
0
zentara
10/6/2004 5:32:16 PM
What I meant was I have a huge canvas which does not fit in the
screen. So taking the snapshot would not work for me since there would
be parts of the canvas not visible in the screen which I would also
like to save. I dont want to scroll down the canvas and take two
different snapshots. I was wondering if I could save the entire canvas
in one go not as a postscript but as a jpeg or any other image file.
Thanks
Karthik

zentara <zentara@highstream.net> wrote in message news:<5ga8m0ppk378ff2voicddf97gvfsroamn6@4ax.com>...
> On 5 Oct 2004 18:22:58 -0700, kars175@yahoo.com (Karthik) wrote:
> 
> >Hi,
> >Is there any perl module to convert a postscript file to a jpeg or gif
> >format. I create the postscript file from a canvas object which dumps
> >the display of the canvas to the postscript file. I thought of using
> >WinPhoto to save it in an xpm format but then again I did not know how
> >to save the non visible portions of the window into the xpm file.
> 
> What do you mean "non visible portions"?  WinPhoto should grab
> a screenshot.
> 
> > I
> >thought there might be some modules available for the conversion but
> >couldnt find any out there. Or if there is a way to save the canvas
> >image (both visible and invisible parts) to a suitable file then it
> >would be great for me to use.
> >
> >Thanks for the help in advance.
> >Karthik
0
kars175
10/7/2004 5:51:36 PM
Karthik wrote:

> I was wondering if I could save the entire canvas
> in one go not as a postscript but as a jpeg or any other image file.

My linux installation comes with a variety of ps2* utilities. I'm pretty 
sure similar programs can be found under different OSes. You can dump 
the .ps file, and then invoke the program to convert it to the format 
you need.

--Ala
0
Ala
10/7/2004 11:32:10 PM
On 7 Oct 2004 10:51:36 -0700, kars175@yahoo.com (Karthik) wrote:

>What I meant was I have a huge canvas which does not fit in the
>screen. So taking the snapshot would not work for me since there would
>be parts of the canvas not visible in the screen which I would also
>like to save. I dont want to scroll down the canvas and take two
>different snapshots. I was wondering if I could save the entire canvas
>in one go not as a postscript but as a jpeg or any other image file.
>Thanks
>Karthik

Doh!  I should have thought of that.  If you want an "UGLY" hack with
WinPhoto, you can resize the $mw to include the full-canvas in view
when you take the screenshot.  It probably is still limited by
screensize though. This is pretty worthless, but I'll post it just for
the sake of discussion.

#!/usr/bin/perl
use warnings;
use strict;
use Tk;
use Tk::WinPhoto;
use Tk::JPEG;

#for discussion only, dosn't really work when jpg exceeds screensize
#slow also during capture.

my $mw = tkinit;
$mw->geometry("200x400+100+100");

my $canv = $mw->Scrolled('Canvas',
                      -width=>200,
                      -height=>300,
                      -scrollregion=>[0,0,600,800],
                      -scrollbars=>'osoe')
                      ->pack(-fill=>'both',
                      -expand=>1);
 
# Create line inside the canvas upper area 
$canv->create ('line',1, 1, 100, 100, -fill=>'red');
$canv->createRectangle(10,20,30,40, -fill=>'blue' );

# Create line inside the lower upper area 
$canv->create ('line',1, 500, 100, 600, -fill=>'red');
$canv->createRectangle(10,500,30,600, -fill=>'blue' );

	  
my $canvbutton = $mw->Button(-text=>'Canvas Capture',
                             -command => sub{
                                          $mw->geometry("800x800+0+0");
                                          &canv_capture},
			     )->pack; 
MainLoop;	

##########################################################

sub canv_capture{

$canv->configure(-height=>600, -width =>800);
$mw->update;

my $image = $mw->Photo(-format => 'Window', 
                        -data => oct($canv->id)
		       );

my $pathname = './canvas.'.time.'.jpg';
$image->write($pathname, -format => 'JPEG');

}
##############################################################


-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
0
zentara
10/8/2004 1:40:38 PM
Thanks for all the feedback. I guess I will have to stick with some
external conversion tools to convert ps to image files. The WinPhoto
as you mentioned is very slow.

Thanks again
Karthik
0
kars175
10/12/2004 12:59:15 AM
zentara <zentara@highstream.net> writes:

> On 7 Oct 2004 10:51:36 -0700, kars175@yahoo.com (Karthik) wrote:
> 
> >What I meant was I have a huge canvas which does not fit in the
> >screen. So taking the snapshot would not work for me since there would
> >be parts of the canvas not visible in the screen which I would also
> >like to save. I dont want to scroll down the canvas and take two
> >different snapshots. I was wondering if I could save the entire canvas
> >in one go not as a postscript but as a jpeg or any other image file.
> >Thanks
> >Karthik
> 
> Doh!  I should have thought of that.  If you want an "UGLY" hack with
> WinPhoto, you can resize the $mw to include the full-canvas in view
> when you take the screenshot.  It probably is still limited by
> screensize though. This is pretty worthless, but I'll post it just for
> the sake of discussion.
> 

As the canvas widget is vector oriented, it should be possible to use
scale() to shrink the contents to the visible screensize and create a
snapshot without loss of information.

Regards,
        Slaven

-- 
Slaven Rezic - slaven <at> rezic <dot> de

    tkruler - Perl/Tk program for measuring screen distances
    http://ptktools.sourceforge.net/#tkruler
0
Slaven
10/19/2004 9:01:09 PM
Reply:

Similar Artilces:

Is there any perl script for converting XML file to tab-delimited file ?
Hello.. I want to load a very big XML file to MySQL database. Because I have already written a script for loading a tab-delimited file to database (specific column to specific field of table) before, I just need to convert the XML file to tab-delimited format. Is there a perl script for solving this kind of problem? I tried to write one this afternoon, but i felt it is not a very easy problem...Can someone give a some hits on it and what XML::* module should I use? ( I used XML::SimpleObject, but I think it is a little light-weighted.) Thanks in advance.. I believe XML::Parser is what your lo...

Perl/unix script to convert a fixed width file to a tab delimited file
Hi all, I have a situtation here. We have a script that reads two delimited (comma or tab or pipe or semicolon or any other) files and compares them returnig the list of records/rows unique to file1, unique to file2 and the mismatches records. Now, we also have to get this going for fixed width files. I know that the inbuilt excel tool, Text to columns, does this. However we need to get this process automated on the unix box. Any suggestions? If someone can help me with the scipt itself, that'll be awesome. Thanks a lot. Regards Srikant In article <1191072950....

convert a dos batch file into perl without using any modules.
The below mentioned thing is a dos batch file. Can I write the whole thing in perl without using any modules like file::compare, etc. check32 pd k0018f00 > test.log fc /l good1.log test.log > comp.log find "no differences encountered" comp.log if errorlevel 1 goto end echo Passed test. del test.log del comp.log check32 pd k0018090 > test.log fc /l good2.log test.log > comp.log find "no differences encountered" comp.log if errorlevel 1 goto end echo Passed test. del test.log del comp.log check32 pd k0018088 > test.log fc /l good3.log test.log > comp.log...

FAQ 5.35 Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl?
This message is one of several periodic postings to comp.lang.perl.misc intended to make it easier for perl programmers to find answers to common questions. The core of this message represents an excerpt from the documentation provided with Perl. -------------------------------------------------------------------- 5.35: Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? This is elaborately and painstakingly described in the file-dir-perms article in the "Far More Than You Ever Wanted To Know" collec...

FAQ 5.36 Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl?
This message is one of several periodic postings to comp.lang.perl.misc intended to make it easier for perl programmers to find answers to common questions. The core of this message represents an excerpt from the documentation provided with Perl. -------------------------------------------------------------------- 5.36: Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? This is elaborately and painstakingly described in the file-dir-perms article in the "Far More Than You Ever Wanted To Know" collec...

FAQ 5.37 Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl?
This is an excerpt from the latest version perlfaq5.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 5.37: Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? This is elaborately and painstakingly described in the file-dir-perms ar...

FAQ 5.38 Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? 311607
This is an excerpt from the latest version perlfaq5.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 5.38: Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? This is elaborately and painstakingly described in the file-dir-perms ar...

FAQ 5.37 Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? #8
This is an excerpt from the latest version perlfaq5.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 5.37: Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? This is elaborately and painstakingly described in the file-dir-perms article in th...

FAQ 5.38 Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? #3
This is an excerpt from the latest version perlfaq5.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 5.38: Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? This is elaborately and painstakingly described in the file-dir-perms article in th...

FAQ 5.38 Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? #4
This is an excerpt from the latest version perlfaq5.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 5.38: Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? This is elaborately and painstakingly described in the file-dir-perms article in th...

FAQ 5.37 Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? #2
This is an excerpt from the latest version perlfaq5.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 5.37: Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? This is elaborately and painstakingly described in the file-dir-perms article in th...

FAQ 5.37 Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? #7
This is an excerpt from the latest version perlfaq5.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 5.37: Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? This is elaborately and painstakingly described in the file-dir-perms article in th...

FAQ 5.38 Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? 475604
This is an excerpt from the latest version perlfaq5.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 5.38: Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? This is elaborately and painstakingly described in the file-dir-perms ar...

FAQ 5.37 Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? #5
This is an excerpt from the latest version perlfaq5.pod, which comes with the standard Perl distribution. These postings aim to reduce the number of repeated questions as well as allow the community to review and update the answers. The latest version of the complete perlfaq is at http://faq.perl.org . -------------------------------------------------------------------- 5.37: Why does Perl let me delete read-only files? Why does "-i" clobber protected files? Isn't this a bug in Perl? This is elaborately and painstakingly described in the file-dir-perms article in th...

Web resources about - perl module to convert a postscript image file to a jpeg/gif/xpm file - comp.lang.perl.tk

PostScript - Wikipedia, the free encyclopedia
The concepts of the PostScript language were seeded in 1976 when John Warnock was working at Evans & Sutherland , a computer graphics company. ...

John Eligon - A postscript to my interview with white... - Facebook
A postscript to my interview with white nationalist, Paul Craig Cobb ... I had knocked on doors in high-crime neighborhoods, spent time interviewing... ...

Flickr: PostScript.EdmontonJournal's Photostream
Explore PostScript.EdmontonJournal's photostream on Flickr. This user has 138 photos on Flickr.

Admire Rakti death a sad Cup postscript
... and died after finishing last in the Melbourne Cup. Favourite Admire Rakti collapsed and died after the Melbourne Cup, adding a sad postscript ...

A postscript to 'The Killing Season': Was there a coup d'etat over mining tax?
Sarah Ferguson's ABC series left one crucial question unanswered.


TFS Kanban talk in Indianapolis, postscript
I've been wanting to write this since giving a talk last week at the Indianapolis TFS user group. Paul Hacker started this group and leads the ...

Potter postscript: 10 great, and 10 not-so-great, things about Harry Potter (Plus: The best scenes) ...
As the Harry Potter film series reaches the end of the story, we look back on the highs and lows of the Harry Potter phenomenon.

Postscript from Penn State-Loyola Maryland men's lacrosse
The Loyola Maryland men&rsquo;s lacrosse team likes to pepper opposing goalkeepers with shots. But the offense prefers to have a little production ...

Sunday Classics preview: A Leon Fleisher postscript
... this July 1956 Epic Debussy-Ravel LP. by Ken No, no, Fleisher hasn't died at least not that I know. What I mean in the post title is a "postscript" ...

Resources last updated: 2/6/2016 6:04:21 PM