Permalink
Browse files

re #14089 revert back to proper erl_img from jungerl + matthew fixes

  • Loading branch information...
1 parent 1b27c17 commit 89e1559194d787af752556de1d39476723015231 Emad El-Haraty committed Jul 1, 2010
Showing with 427 additions and 99 deletions.
  1. +0 −35 src/Makefile
  2. +1 −1 src/image_gif.erl
  3. +46 −57 src/image_jpeg.erl
  4. +1 −2 src/image_png.erl
  5. +379 −3 src/image_tiff.erl
  6. +0 −1 src/image_undef.erl
View
@@ -1,35 +0,0 @@
-
-EBIN = ../ebin
-ERLC = erlc
-ERLC_FLAGS = -I../include
-
-OBJS = $(EBIN)/image_bmp.beam \
- $(EBIN)/image_x_xpixmap.beam \
- $(EBIN)/image_png.beam \
- $(EBIN)/image_gif.beam \
- $(EBIN)/image_jpeg.beam \
- $(EBIN)/image_tiff.beam \
- $(EBIN)/image_undef.beam \
- $(EBIN)/video_mpeg.beam \
- $(EBIN)/exif.beam \
- $(EBIN)/lzw.beam \
- $(EBIN)/erl_img.beam
-
-
-debug: ERLC_FLAGS += -Ddebug
-
-
-all: $(OBJS)
-
-debug: all
-
-
-$(OBJS): ../include/erl_img.hrl
-
-$(EBIN)/image_tiff.beam: tiff.hrl
-$(EBIN)/image_jpeg.beam: jpeg.hrl exif.hrl
-$(EBIN)/exif.beam: exif.hrl
-
-$(EBIN)/%.beam: %.erl
- $(ERLC) $(ERLC_FLAGS) -o $(EBIN) $<
-
View
@@ -5,7 +5,7 @@
-module(image_gif).
--include_lib("erl_img/include/erl_img.hrl").
+-include("erl_img.hrl").
-include("api.hrl").
View
@@ -27,8 +27,8 @@
-magic(<<?M_SOI:16,?M_APP1:16,_Len:16,"Exif",0,0,_/binary>>) -> true;
-magic(<<?M_SOI:16,?M_JFIF:16,_Len:16,"JFIF",_,_,_/binary>>) -> true;
+magic(<<?M_SOI:16,?M_APP1:16,Len:16,"Exif",0,0,_/binary>>) -> true;
+magic(<<?M_SOI:16,?M_JFIF:16,Len:16,"JFIF",_,_,_/binary>>) -> true;
magic(_) -> false.
mime_type() -> "image/jpeg".
@@ -48,17 +48,17 @@ read_info(Fd) ->
Error -> Error
end.
-write_info(_Fd, _IMG) ->
+write_info(Fd, _IMG) ->
ok.
read(_Fd,IMG) ->
{ok,IMG}.
-read(_Fd,IMG,_RowFun,_St0) ->
+read(_Fd,IMG,RowFun,St0) ->
{ok,IMG}.
-write(_Fd,_IMG) ->
+write(_Fd,IMG) ->
ok.
@@ -115,95 +115,95 @@ read_section(Fd,Marker,Len,IMG) ->
read_sections(Fd, IMG)
end.
-process_sofn(<<Depth:8,Height:16,Width:16,_Components:8,_Bin/binary>>, IMG) ->
+process_sofn(<<Depth:8,Height:16,Width:16,_Components:8,Bin/binary>>, IMG) ->
IMG#erl_image { depth = Depth,
height = Height,
width = Width }.
%% Maker OLYMP
collect_olymp(_Fd, T, St) ->
- _Key = erl_img:hex16(T#tiff_entry.tag),
+ Key = erl_img:hex16(T#tiff_entry.tag),
?dbg("OLYMP(~s) ~p ~p ~p\n",
- [T#tiff_entry.ifd,_Key,T#tiff_entry.type, T#tiff_entry.value]),
+ [T#tiff_entry.ifd,Key,T#tiff_entry.type, T#tiff_entry.value]),
St.
%% Maker Nikon
collect_nikon(_Fd, T, St) ->
- _Key = erl_img:hex16(T#tiff_entry.tag),
+ Key = erl_img:hex16(T#tiff_entry.tag),
?dbg("Nikon(~s) ~p ~p ~p\n",
- [T#tiff_entry.ifd,_Key,T#tiff_entry.type, T#tiff_entry.value]),
+ [T#tiff_entry.ifd,Key,T#tiff_entry.type, T#tiff_entry.value]),
St.
%% Maker FUJIFILM
collect_fujifilm(_Fd, T, St) ->
- _Key = erl_img:hex16(T#tiff_entry.tag),
+ Key = erl_img:hex16(T#tiff_entry.tag),
?dbg("Fujifilm(~s) ~p ~p ~p\n",
- [T#tiff_entry.ifd,_Key,T#tiff_entry.type, T#tiff_entry.value]),
+ [T#tiff_entry.ifd,Key,T#tiff_entry.type, T#tiff_entry.value]),
St.
%% Maker Sony DSC
collect_sony(_Fd, T, St) ->
- _Key = erl_img:hex16(T#tiff_entry.tag),
+ Key = erl_img:hex16(T#tiff_entry.tag),
?dbg("Sony(~s) ~p ~p ~p\n",
- [T#tiff_entry.ifd,_Key,T#tiff_entry.type, T#tiff_entry.value]),
+ [T#tiff_entry.ifd,Key,T#tiff_entry.type, T#tiff_entry.value]),
St.
%% Maker other
collect_other(_Fd, T, St) ->
- _Key = erl_img:hex16(T#tiff_entry.tag),
+ Key = erl_img:hex16(T#tiff_entry.tag),
?dbg("Maker(~s) ~p ~p ~p\n",
- [T#tiff_entry.ifd,_Key,T#tiff_entry.type, T#tiff_entry.value]),
+ [T#tiff_entry.ifd,Key,T#tiff_entry.type, T#tiff_entry.value]),
St.
-collect_maker(_Fd, _T, St) ->
+collect_maker(_Fd, T, St) ->
{ok, St}.
collect_maker_fixme(Fd, T, St) ->
?dbg("Tif entry=~p\n", [T]),
MakerBin = T#tiff_entry.value,
case MakerBin of
<<"OLYMP",0,1,0,_/binary>> ->
- tiff:scan_ifd(Fd,
- [$0,$:|T#tiff_entry.ifd],
- T#tiff_entry.offs+8,
- T#tiff_entry.endian,
- fun collect_olymp/3, St);
+ image_tiff:scan_ifd(Fd,
+ [$0,$:|T#tiff_entry.ifd],
+ T#tiff_entry.offs+8,
+ T#tiff_entry.endian,
+ fun collect_olymp/3, St);
<<"Nikon",0,1,0,_/binary>> ->
- tiff:scan_ifd(Fd,
- [$0,$:|T#tiff_entry.ifd],
- T#tiff_entry.offs+8,
- T#tiff_entry.endian,
- fun collect_nikon/3, St);
+ image_tiff:scan_ifd(Fd,
+ [$0,$:|T#tiff_entry.ifd],
+ T#tiff_entry.offs+8,
+ T#tiff_entry.endian,
+ fun collect_nikon/3, St);
<<"SONY DSC ",0,0,0,_/binary>> ->
%% NOT working - what is SONY doing ?
- tiff:scan_ifd(Fd,
- [$0,$:|T#tiff_entry.ifd],
- T#tiff_entry.offs+14,
- T#tiff_entry.endian,
- fun collect_sony/3, St);
+ image_tiff:scan_ifd(Fd,
+ [$0,$:|T#tiff_entry.ifd],
+ T#tiff_entry.offs+14,
+ T#tiff_entry.endian,
+ fun collect_sony/3, St);
<<"FUJIFILM",Offset:32/little>> ->
- tiff:scan_ifd_bin(MakerBin,
- [$0,$:|T#tiff_entry.ifd],
- Offset, little,
- fun collect_fujifilm/3, St);
+ image_tiff:scan_ifd_bin(MakerBin,
+ [$0,$:|T#tiff_entry.ifd],
+ Offset, little,
+ fun collect_fujifilm/3, St);
_ ->
- tiff:scan_ifd(Fd,
- [$0,$:|T#tiff_entry.ifd],
- T#tiff_entry.offs+8,
- T#tiff_entry.endian,
- fun collect_other/3, St)
+ image_tiff:scan_ifd(Fd,
+ [$0,$:|T#tiff_entry.ifd],
+ T#tiff_entry.offs+8,
+ T#tiff_entry.endian,
+ fun collect_other/3, St)
end.
collect_exif(Fd, T, St) ->
- _Key = exif:decode_tag(T#tiff_entry.tag),
+ Key = exif:decode_tag(T#tiff_entry.tag),
?dbg("EXIF(~s) ~p ~p ~p\n",
- [T#tiff_entry.ifd,_Key,T#tiff_entry.type, T#tiff_entry.value]),
+ [T#tiff_entry.ifd,Key,T#tiff_entry.type, T#tiff_entry.value]),
case T#tiff_entry.tag of
?ExifInteroperabilityOffset ->
[Offset] = T#tiff_entry.value,
%% could be handle by a collect_interop?
- case tiff:scan_ifd(Fd, [$0,$.|T#tiff_entry.ifd],
+ case image_tiff:scan_ifd(Fd, [$0,$.|T#tiff_entry.ifd],
Offset, T#tiff_entry.endian,
fun collect_exif/3, St) of
{ok, St1} ->
@@ -225,7 +225,7 @@ collect_exif(Fd, T, St) ->
%% Image info collector functions
collect_tiff(Fd, T, St) ->
- Key = tiff:decode_tag(T#tiff_entry.tag),
+ Key = image_tiff:decode_tag(T#tiff_entry.tag),
?dbg("TIFF(~s) ~p ~p ~p\n",
[T#tiff_entry.ifd,Key,T#tiff_entry.type, T#tiff_entry.value]),
case T#tiff_entry.tag of
@@ -257,25 +257,14 @@ collect_tiff(Fd, T, St) ->
end;
?ExifOffset ->
[Offset] = T#tiff_entry.value,
- case tiff:scan_ifd(Fd, [$0,$.|T#tiff_entry.ifd],
+ case image_tiff:scan_ifd(Fd, [$0,$.|T#tiff_entry.ifd],
Offset, T#tiff_entry.endian,
fun collect_exif/3, St) of
{ok, St1} ->
St1;
_Error ->
St
end;
- ?GPSInfo ->
- [Offset] = T#tiff_entry.value,
- case tiff:scan_ifd(Fd, [$0,$.|T#tiff_entry.ifd],
- Offset, T#tiff_entry.endian,
- fun gpsinfo:collect_gpsinfo/3, []) of
- {ok, GPSInfo} ->
- As = St#erl_image.attributes,
- St#erl_image { attributes = [{'GPSInfo', GPSInfo}|As]};
- _Error ->
- St
- end;
_ ->
Value = T#tiff_entry.value,
As = St#erl_image.attributes,
View
@@ -5,7 +5,6 @@
-module(image_png).
-
-include_lib("erl_img/include/erl_img.hrl").
-include("api.hrl").
@@ -206,7 +205,7 @@ txt([], _) ->
%% read palette
plte(<<R,G,B, Data/binary>>) ->
- [{R*255,G*255,B*255} | plte(Data)];
+ [{R,G,B} | plte(Data)];
plte(<<>>) -> [].
%% IMPLEMENT This:
Oops, something went wrong.

0 comments on commit 89e1559

Please sign in to comment.