Permalink
Browse files

Merge pull request #3 from Concurix/master

Enhancement to allow reading images already in memory
  • Loading branch information...
2 parents d624f46 + e3a93da commit bf01d6299516acc3043c05cdbc742cee501f97c2 @evanmiller committed Mar 5, 2013
Showing with 6 additions and 5 deletions.
  1. +6 −5 src/erl_img.erl
View
@@ -114,9 +114,13 @@ read_file_info(File) ->
Error -> Error
end.
-
+load(Binary) when is_binary(Binary) ->
+ load_opt(Binary, [ram, binary, read]);
load(File) ->
- case file:open(File, [raw, binary, read]) of
+ load_opt(File, [raw, binary, read]).
+
+load_opt(File, Opts) ->
+ case file:open(File, Opts) of
{ok,Fd} ->
Res = case read_magic_info(Fd) of
{ok, IMG} ->
@@ -156,9 +160,6 @@ to_binary(IMG) ->
Error
end.
-
-
-
read_info(Type, Fd) ->
file:position(Fd, 0),
apply(Type, read_info, [Fd]).

0 comments on commit bf01d62

Please sign in to comment.