From 406794e18f5e803eafebaa2ce9b9db51005622ed Mon Sep 17 00:00:00 2001 From: Stephen Moloney Date: Fri, 10 Mar 2017 19:46:48 +0000 Subject: [PATCH] fix bug #9 in github issues --- lib/fastimage.ex | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/fastimage.ex b/lib/fastimage.ex index fa25c51..b512c7d 100644 --- a/lib/fastimage.ex +++ b/lib/fastimage.ex @@ -92,7 +92,7 @@ defmodule Fastimage do num_chunks_to_fetch == 0 -> {:ok, acc_data, stream_ref} num_chunks_to_fetch > 0 -> - next_chunk = :hackney.stream_next(stream_ref) + _next_chunk = :hackney.stream_next(stream_ref) receive do {:hackney_response, stream_ref, {:status, status_code, reason}} -> cond do @@ -162,15 +162,16 @@ defmodule Fastimage do :sof -> <> = next_data cond do - :true == next_byte in (224..239) -> + :true == (next_byte == 225) -> + # TODO - add option for exif information parsing here + parse_jpeg(stream_ref, {acc_num_chunks, acc_data, url}, next_bytes, num_chunks_to_fetch, chunk_size, :skip) + :true == (next_byte in (224..239)) -> parse_jpeg(stream_ref, {acc_num_chunks, acc_data, url}, next_bytes, num_chunks_to_fetch, chunk_size, :skip) :true == [(192..195), (197..199), (201..203), (205..207)] |> Enum.any?(fn(range) -> next_byte in range end) -> parse_jpeg(stream_ref, {acc_num_chunks, acc_data, url}, next_bytes, num_chunks_to_fetch, chunk_size, :read) - :true == next_byte == 255 -> + :true == (next_byte == 255) -> parse_jpeg(stream_ref, {acc_num_chunks, acc_data, url}, next_bytes, num_chunks_to_fetch, chunk_size, :sof) - :true == next_byte == 225 -> - parse_jpeg(stream_ref, {acc_num_chunks, acc_data, url}, next_bytes, num_chunks_to_fetch, chunk_size, :skip) :true -> parse_jpeg(stream_ref, {acc_num_chunks, acc_data, url}, next_bytes, num_chunks_to_fetch, chunk_size, :skip) end