Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Enhancement to allow reading images already in memory #3

Merged
merged 2 commits into from about 1 year ago

3 participants

solleks Evan Miller Alexander Gounares
solleks

Still learning how pull requests work. This one is a superset of the last one.

The second commit allows one to load an image contained in a binary, using the "ram" option of file:open.

Evan Miller
Owner

Thanks!

Evan Miller evanmiller merged commit bf01d62 into from March 04, 2013
Evan Miller evanmiller closed this March 04, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
11  src/erl_img.erl
@@ -114,9 +114,13 @@ read_file_info(File) ->
114 114
         Error  -> Error
115 115
     end.
116 116
 
117  
-
  117
+load(Binary) when is_binary(Binary) ->
  118
+	load_opt(Binary, [ram, binary, read]);
118 119
 load(File) ->
119  
-    case file:open(File, [raw, binary, read]) of
  120
+	load_opt(File, [raw, binary, read]).
  121
+
  122
+load_opt(File, Opts) ->
  123
+    case file:open(File, Opts) of
120 124
         {ok,Fd} ->
121 125
             Res = case read_magic_info(Fd) of
122 126
                       {ok, IMG} ->
@@ -156,9 +160,6 @@ to_binary(IMG) ->
156 160
             Error
157 161
     end.
158 162
 
159  
-
160  
-
161  
-
162 163
 read_info(Type, Fd) ->
163 164
     file:position(Fd, 0),
164 165
     apply(Type, read_info, [Fd]).
5  src/image_png.erl
@@ -52,8 +52,9 @@ scan_info(Fd, IMG, First) ->
52 52
     case read_chunk_hdr(Fd) of
53 53
         {ok, Length, Type} ->
54 54
             Z = zlib:open(),
55  
-            scan_info(Fd, IMG, First, Type, Length, Z),
56  
-            zlib:close(Z);
  55
+            Res = scan_info(Fd, IMG, First, Type, Length, Z),
  56
+            zlib:close(Z),
  57
+			Res;
57 58
         Error ->
58 59
             Error
59 60
     end.
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.