PATH:
usr
/
share
/
ghostscript
/
lib
%! viewjpeg.ps Copyright (C) 1994 Thomas Merz <tm@pdflib.com> % % This software is provided AS-IS with no warranty, either express or % implied. % % This software is distributed under license and may not be copied, % modified or distributed except as expressly authorized under the terms % of the license contained in the file LICENSE in this distribution. % % For more information about licensing, please refer to % http://www.ghostscript.com/licensing/. For information on % commercial licensing, go to http://www.artifex.com/licensing/ or % contact Artifex Software, Inc., 1305 Grant Avenue - Suite 200, % Novato, CA 94945, U.S.A., +1(415)492-9861. % View JPEG files with Ghostscript % % This PostScript code relies on level 2 features. % % Only JPEG baseline, extended sequential, and progressive files % are supported. Note that Adobe PostScript level 2 does not include % progressive-JPEG support. Ghostscript with IJG JPEG v6 or later % will decode progressive JPEG, but only if you edit gsjmorec.h to % enable that feature. % % Author's address: % ------------------------------+ % {(pstack exec quit) = flush } | Thomas Merz, Munich % pstack exec quit | voice +49/89/29160728 % ------------------------------+ tm@muc.de http://www.muc.de/~tm/ % % Updated by L. Peter Deutsch 20-May-1997: % move the usage example to the beginning % Updates by Tom Lane 6-Sep-1995 % Usage example: % (jpeg-6/testimg.jpg) viewJPEG /languagelevel where {pop languagelevel 2 lt}{true} ifelse { (JPEG needs PostScript Level 2!\n) print flush stop } if /JPEGdict 20 dict def JPEGdict begin /NoParamMarkers [ % JPEG markers without additional parameters 16#D0 16#D1 16#D2 16#D3 16#D4 16#D5 16#D6 16#D7 16#D8 16#01 ] def /NotSupportedMarkers [ % JPEG markers not supported by PostScript level 2 16#C3 16#C5 16#C6 16#C7 16#C8 16#C9 16#CA 16#CB 16#CD 16#CE 16#CF ] def % Names of color spaces /ColorSpaceNames << /1 /DeviceGray /3 /DeviceRGB /4 /DeviceCMYK >> def % read one byte from file F % - ==> int --or-- stop context /NextByte { F read not { (Read error in ViewJPEG!\n) print flush stop } if } bind def /SkipSegment { % read two bytes and skip that much data NextByte 8 bitshift NextByte add 2 sub { NextByte pop } repeat } bind def % read width, height, and # of components from JPEG markers % and store in dict /readJPEGmarkers { % - ==> dict --or-- stop context 5 dict begin { % loop: read JPEG marker segments until we find SOFn marker or EOF NextByte 16#FF eq { % found marker /markertype NextByte def % Is it S0F0=baseline, SOF1=extended sequential, SOF2=progressive ? markertype dup 16#C0 ge exch 16#C2 le and { NextByte pop NextByte pop % segment length % Ghostscript and Adobe PS accept only data precision 8 NextByte 8 ne { (Error: not 8 bits per component!\n) print flush stop } if % Read crucial image parameters /height NextByte 8 bitshift NextByte add def /width NextByte 8 bitshift NextByte add def /colors NextByte def VJPGDEBUG { currentdict { exch == == } forall flush } if exit } if % detect several segment types which are not compatible with PS NotSupportedMarkers { markertype eq { (Marker ) print markertype == (not supported!\n) print flush stop } if } forall % Skip segment if marker has parameters associated with it true NoParamMarkers { markertype eq {pop false exit} if } forall { SkipSegment } if } if } loop currentdict dup /markertype undef end } bind def end % JPEGdict % read image parameters from JPEG file and display the image /viewJPEG { % <file|string> ==> - save JPEGdict begin /saved exch def /scratch 1 string def dup type /stringtype eq { (r) file } if /F exch def readJPEGmarkers begin F 0 setfileposition % reset file pointer % We use the whole clipping area for the image (at least in one dimension) gsave clippath pathbbox grestore /ury exch def /urx exch def /lly exch def /llx exch def llx lly translate width height scale % use whole width or height, whichever is appropriate urx llx sub width div ury lly sub height div 2 copy gt { exch } if pop % min dup scale ColorSpaceNames colors scratch cvs get setcolorspace % prepare image dictionary << /ImageType 1 /Width width /Height height /ImageMatrix [ width 0 0 height neg 0 height ] /BitsPerComponent 8 % If 4-component (CMYK), assume data is inverted per Adobe Photoshop colors 4 eq { /Decode [ colors { 1 0 } repeat ] } { /Decode [ colors { 0 1 } repeat ] } ifelse /DataSource F /DCTDecode filter >> image end % image parameter dictionary saved end restore } bind def % This lets you do stuff on the command line like: % gs -sDEVICE=pdfwrite -o stuff%03d.pdf viewjpeg.ps -c "(image.jpg) << /PageSize 2 index viewJPEGgetsize 2 array astore >> setpagedevice viewJPEG" % so the output size matches the original image. /viewJPEGgetsize { % <file|string> ==> width height save JPEGdict begin /saved exch def /scratch 1 string def dup type /stringtype eq { (r) file } if /F exch def readJPEGmarkers begin F 0 setfileposition % reset file pointer width height saved end restore } bind def
[-] rollconv.ps
[edit]
[-] acctest.ps
[edit]
[-] bjc610b7.upp
[edit]
[-] viewps2a.ps
[edit]
[-] ras3.upp
[edit]
[-] stc1520h.upp
[edit]
[-] stc800p.upp
[edit]
[-] PM820p.upp
[edit]
[-] st640ih.upp
[edit]
[-] stc_l.upp
[edit]
[-] bj8gc12f.upp
[edit]
[-] bj8oh06n.upp
[edit]
[-] viewmiff.ps
[edit]
[-] docie.ps
[edit]
[-] viewgif.ps
[edit]
[-] gs_wl2_e.ps
[edit]
[-] printafm.ps
[edit]
[-] Stp720p.upp
[edit]
[-] st640plg.upp
[edit]
[-] sipixa6.upp
[edit]
[-] lines.ps
[edit]
[-] caption.ps
[edit]
[-] bjc610a0.upp
[edit]
[-] cbjc600.ppd
[edit]
[-] pphs.ps
[edit]
[-] bjc6000a1.upp
[edit]
[-] dnj750m.upp
[edit]
[-] cdj690ec.upp
[edit]
[-] viewpbm.ps
[edit]
[-] Stp720pl.upp
[edit]
[-] cdj550.upp
[edit]
[-] Stc670p.upp
[edit]
[+]
..
[-] gs_il2_e.ps
[edit]
[-] ras24.upp
[edit]
[-] gs_t.xpm
[edit]
[-] bjc610b6.upp
[edit]
[-] stocht.ps
[edit]
[-] viewpcx.ps
[edit]
[-] gs_l_m.xbm
[edit]
[-] gs_s.xbm
[edit]
[-] image-qa.ps
[edit]
[-] landscap.ps
[edit]
[-] dmp_site.ps
[edit]
[-] bjc610a4.upp
[edit]
[-] necp2x.upp
[edit]
[-] align.ps
[edit]
[-] ps2epsi.ps
[edit]
[-] gslp.ps
[edit]
[-] stc740ih.upp
[edit]
[-] bj8.rpd
[edit]
[-] gs_ce_e.ps
[edit]
[-] st640ihg.upp
[edit]
[-] ghostpdf.ppd
[edit]
[-] stc600ih.upp
[edit]
[-] Stc680pl.upp
[edit]
[-] stc.upp
[edit]
[-] stcany_h.upp
[edit]
[-] gs_t_m.xbm
[edit]
[-] stcinfo.ps
[edit]
[-] gs_wl5_e.ps
[edit]
[-] stc500ph.upp
[edit]
[-] gs_wl1_e.ps
[edit]
[-] stc300bl.upp
[edit]
[-] gs_l.xpm
[edit]
[-] ras32.upp
[edit]
[-] winmaps.ps
[edit]
[-] stc500p.upp
[edit]
[-] bjc6000b1.upp
[edit]
[-] mkcidfm.ps
[edit]
[-] pdf2dsc.ps
[edit]
[-] bjc610b8.upp
[edit]
[-] pf2afm.ps
[edit]
[-] s400b1.upp
[edit]
[-] traceimg.ps
[edit]
[-] traceop.ps
[edit]
[-] Stc760pl.upp
[edit]
[-] stc300bm.upp
[edit]
[-] st640pg.upp
[edit]
[-] stc600p.upp
[edit]
[-] st640p.upp
[edit]
[-] Stc777p.upp
[edit]
[-] uninfo.ps
[edit]
[-] ps2ai.ps
[edit]
[-] gs_l.xbm
[edit]
[-] bjc610a2.upp
[edit]
[-] gs_t.xbm
[edit]
[-] bj8hg12f.upp
[edit]
[-] Stp870pl.upp
[edit]
[-] prfont.ps
[edit]
[-] bj8pa06n.upp
[edit]
[-] gs_lgo_e.ps
[edit]
[-] gs_ksb_e.ps
[edit]
[-] stc800pl.upp
[edit]
[-] gs_kanji.ps
[edit]
[-] font2pcl.ps
[edit]
[-] Stc740p.upp
[edit]
[-] stc200_h.upp
[edit]
[-] bjc610a8.upp
[edit]
[-] viewjpeg.ps
[edit]
[-] pfbtopfa.ps
[edit]
[-] bjc610b2.upp
[edit]
[-] necp2x6.upp
[edit]
[-] gs_s.xpm
[edit]
[-] jispaper.ps
[edit]
[-] ppath.ps
[edit]
[-] ras4.upp
[edit]
[-] bjc610a1.upp
[edit]
[-] Stc777pl.upp
[edit]
[-] Stc760p.upp
[edit]
[-] stc300.upp
[edit]
[-] stcany.upp
[edit]
[-] gs_s_m.xbm
[edit]
[-] stc_h.upp
[edit]
[-] ras8m.upp
[edit]
[-] bjc610a6.upp
[edit]
[-] gs_m_m.xbm
[edit]
[-] gs_m.xpm
[edit]
[-] stc600pl.upp
[edit]
[-] stc2s_h.upp
[edit]
[-] bjc610a7.upp
[edit]
[-] PM820pl.upp
[edit]
[-] cid2code.ps
[edit]
[-] bjc610a5.upp
[edit]
[-] stc640p.upp
[edit]
[-] ht_ccsto.ps
[edit]
[-] cdj690.upp
[edit]
[-] st640pl.upp
[edit]
[-] PDFX_def.ps
[edit]
[-] bjc610a3.upp
[edit]
[-] zeroline.ps
[edit]
[-] dmp_init.ps
[edit]
[-] Stc680p.upp
[edit]
[-] PM760p.upp
[edit]
[-] bjc610b3.upp
[edit]
[-] PM760pl.upp
[edit]
[-] sharp.upp
[edit]
[-] stc2_h.upp
[edit]
[-] bj8ts06n.upp
[edit]
[-] stc800ih.upp
[edit]
[-] bjc610b4.upp
[edit]
[-] dnj750c.upp
[edit]
[-] bj8pp12f.upp
[edit]
[-] stc2.upp
[edit]
[-] s400a1.upp
[edit]
[-] bjc610b1.upp
[edit]
[-] viewcmyk.ps
[edit]
[-] PDFA_def.ps
[edit]
[-] cbjc800.ppd
[edit]
[-] ras1.upp
[edit]
[-] gs_lgx_e.ps
[edit]
[-] Stp870p.upp
[edit]
[-] escp_24.src
[edit]
[-] stcolor.ps
[edit]
[-] Stc740pl.upp
[edit]
[-] gs_m.xbm
[edit]
[-] Stc670pl.upp
[edit]
[-] gsnup.ps
[edit]