You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

64 lines
2.1 KiB

1 month ago
  1. % Copyright (C) 2001-2023 Artifex Software, Inc.
  2. % All Rights Reserved.
  3. %
  4. % This software is provided AS-IS with no warranty, either express or
  5. % implied.
  6. %
  7. % This software is distributed under license and may not be copied,
  8. % modified or distributed except as expressly authorized under the terms
  9. % of the license contained in the file LICENSE in this distribution.
  10. %
  11. % Refer to licensing information at http://www.artifex.com or contact
  12. % Artifex Software, Inc., 39 Mesa Street, Suite 108A, San Francisco,
  13. % CA 94129, USA, for further information.
  14. %
  15. % viewcmyk.ps
  16. % Display a raw CMYK file.
  17. % Requires the colorimage operator.
  18. % If SCALE is defined, maps input pixels to output pixels with that scale;
  19. % if SCALE is undefined, scales the image to fit the page.
  20. % If BITS is defined, it is the number of bits per sample (1,2,4,8,12);
  21. % if BITS is undefined, its default value is 1.
  22. /viewcmyk { % <filename> <width> viewcmyk -
  23. 20 dict begin
  24. /w exch def
  25. /fname exch def
  26. /bpc /BITS where { pop BITS } { 1 } ifelse def
  27. /f fname (r) file def
  28. mark fname status pop pop pop /flen exch def cleartomark
  29. /h flen w bpc 4 mul mul 7 add 8 idiv idiv def
  30. (Dimensions: ) print [w h] == flush
  31. % Set up scaling.
  32. /SCALE where {
  33. pop
  34. % Map pixels SCALE-for-1. Assume orthogonal transformation.
  35. SCALE 1 0 dtransform add abs div
  36. SCALE 0 1 dtransform add abs div
  37. } {
  38. % Scale the image (uniformly) to fit the page.
  39. clippath pathbbox pop pop translate
  40. pathbbox 3 -1 roll sub h div
  41. 3 1 roll exch sub w div .min dup
  42. } ifelse scale
  43. w h bpc [1 0 0 -1 0 h] f false 4 colorimage
  44. showpage
  45. f closefile
  46. end
  47. } bind def
  48. % If the program was invoked from the command line, run it now.
  49. [ .shellarguments {
  50. counttomark 2 eq {
  51. cvi viewcmyk
  52. } {
  53. cleartomark
  54. (Usage: gs -- viewcmyk.ps filename.cmyk width\n) print
  55. ( e.g.: gs -- viewcmyk.ps my.cmyk 2550\n) print flush
  56. (From version 9.50 you must supply permissions for this program to read the input file(s)\n) print flush
  57. (either by using -dNOSAFER or by supplying --permit-file-read=<filename>\n) = flush
  58. } ifelse
  59. } {
  60. pop
  61. } ifelse