1 ! Copyright (C) 2009 Keith Lazuka.
2 ! See http://factorcode.org/license.txt for BSD license.
3 USING: fry images.loader images.normalization images.viewer io
4 io.directories io.encodings.binary io.files io.pathnames
5 io.streams.byte-array kernel locals namespaces quotations
6 sequences serialize tools.test ;
11 : fig-name ( path -- newpath )
12 [ parent-directory canonicalize-path ]
13 [ file-stem ".fig" append ] bi
18 :: with-matching-files ( dirpath extension quot -- )
21 dup file-extension extension = quot [ drop ] if
23 ] with-directory-files ; inline
25 : images. ( dirpath extension -- )
26 [ image. ] with-matching-files ;
28 : ls ( dirpath extension -- )
29 [ "\"" dup surround print ] with-matching-files ;
31 : save-as-reference-image ( path -- )
32 [ load-image ] [ fig-name ] bi
33 binary [ serialize ] with-file-writer ;
35 : save-all-as-reference-images ( dirpath extension -- )
36 [ save-as-reference-image ] with-matching-files ;
38 : load-reference-image ( path -- image )
39 fig-name binary [ deserialize ] with-file-reader ;
41 :: encode-test ( path image-class -- )
43 path load-image dup clone normalize-image 1quotation swap
45 binary [ _ image-class image>stream ] with-byte-writer
46 image-class load-image* normalize-image
50 : decode-test ( path -- )
52 [ load-image 1quotation ]
53 [ '[ _ load-reference-image ] ] bi