fresco icon indicating copy to clipboard operation
fresco copied to clipboard

Streaming Progressive JPEGs didn't work

Open johnnypramadya opened this issue 11 years ago • 13 comments

@Override public NewsEventHolder onCreateViewHolder(ViewGroup parent, int viewType) { SimpleProgressiveJpegConfig jpegConfig = new SimpleProgressiveJpegConfig(); jpegConfig.getNextScanNumberToDecode(1); jpegConfig.getQualityInfo(1);

    ImagePipelineConfig config = ImagePipelineConfig.newBuilder(context)
            .setProgressiveJpegConfig(jpegConfig)
            .build();

    Fresco.initialize(context,config);
    View v = LayoutInflater.from(context).inflate(R.layout.item_news_event, parent, false);
    return new NewsEventHolder(v);
}

@Override public void onBindViewHolder(NewsEventHolder holder, int position) { holder.txtTitle.setText(itemNewsEvents.get(position).getTitle()); holder.txtDate.setText(itemNewsEvents.get(position).getDate());

    Uri myUri = Uri.parse(itemNewsEvents.get(position).getImg());

    ImageRequest request = ImageRequestBuilder.newBuilderWithSource(myUri)
            .setProgressiveRenderingEnabled(true)
            .build();
    DraweeController controller = Fresco.newDraweeControllerBuilder()
            .setImageRequest(request)
            .setOldController(holder.draweeView.getController())
            .build();
    holder.draweeView.setController(controller);
}

johnnypramadya avatar Apr 13 '15 08:04 johnnypramadya

What URI are you hitting?

tyronen avatar Apr 13 '15 21:04 tyronen

https://img.okezone.com//content/2015/03/13/20/1117973/dirjen-pajak-blunder-soal-pajak-jalan-tol-Hhkw9dov48.jpg

The image has appeared in my RecyclerView but The Streaming progressive jpeg didn't work. It should have seen the quality of the image start out low and gradually become clearer.

johnnypramadya avatar Apr 13 '15 23:04 johnnypramadya

I took a look at the image in a hex editor. I am not sure the contents of the file are correct.

A progressive JPEG should have a SOF2 marker (0xFFC2). Your image has a SOF0 marker (0xFFC0) which indicates it is a baseline image.

I do see that you have three SOS markers, which would be consistent with a progressive image with three scans. You may want to check the encoding of this image.

tyronen avatar Apr 14 '15 22:04 tyronen

That image loaded in a baseline fashion for me as well. IT seems that the image is not a progressive jpeg. Not all jpegs are progressive.

plamenko avatar Apr 17 '15 01:04 plamenko

I see, Thank you..

johnnypramadya avatar Apr 19 '15 12:04 johnnypramadya

is there any library for making progressive jpeg in android ?

johnnypramadya avatar Apr 19 '15 12:04 johnnypramadya

What do you mean by making a progressive jpeg? If you are downloading the image from network, then there is not much you can do if the image is not already in the progressive format, as you'd have to download it fully after which makes no sense transcoding it. If you'd like to save a local image as a progressive jpeg, we use lib-jpeg-turbo library under the hood, but I'm not sure whether it can produce the progressive jpegs or not. Even if it can, at the moment we don't expose this functionality. We can only read progressive jpegs. Keep in mind that even if you upload some progressive image from your phone to some server, there is a good chance that the server will transcode that image in which case it makes very little difference in what format you've sent the image.

plamenko avatar Apr 19 '15 14:04 plamenko

is there any sample code for Streaming Progressive JPEG ?

i'm using this uri progressive jpeg and it still doesn't work http://pooyak.com/p/progjpeg/jpegload.cgi?o=1

johnnypramadya avatar Apr 20 '15 04:04 johnnypramadya

Ok, I see. Yes, that image does load as a baseline.

tyronen avatar Apr 20 '15 10:04 tyronen

I am working on fixing this bug.

plamenko avatar Apr 21 '15 19:04 plamenko

Fixed in release 0.5.0

tyronen avatar May 15 '15 13:05 tyronen

@tyronen hi, I suffered this bug too, and fix my app with release 0.5.0.But I look forward when the source code of 0.5.0 will be release~? Thx a log ~

sminger1202 avatar Jun 01 '15 07:06 sminger1202

The source of 0.5.0 is already released. From the repo, just select the tag v0.5.0.

tyronen avatar Jun 07 '15 23:06 tyronen