News for hackers. Stuff that matters.
Re:BPG Image format by pslam on Friday December 05, 2014 @05:57PM (#8707426)
The big story here is this introduces a new image file format without requiring you to upgrade a browser or download a plugin. Those aren't PNGs of representative images you're looking at - that's BPG decoding happening in your browser.

So we don't like HVEC due to patent worries? Fine, we can swap in another format and use the same technique.

We don't have an I-frame format for Daala that's finalized yet? Fine, we can use work-in-progress. The format does not need to be finalized. If you update it, you rebuild your images and bundle a new JavaScript decoder.

The ability to ship media along with a sandboxed, runnable decoder is awesome, and I'm surprised it hasn't caught on until now. I remember Google a while back implemented their own "video" codec in JavaScript using JPEGs and primitive inter-frame processing, exactly because there wasn't a universal video codec format they could use.

Re:BPG Image format by keeperofdakeys on Friday December 05, 2014 @07:12PM (#8707728)
Does the javascript decoder download the images, or does the browser do that, then the javascript simply decode it? If it downloads them itself, then any parallel fetching by browsers will stop working. And if they are decoded by javascript, they will take (very slightly) longer, and both the encoded and decoded images need to be held in memory both in javascript, and the browser. Are they decoded to .bmp, .jpg, .png? Can CSS reference them without javascript changing the styles? Can they be cached locally if downloaded directly?

If you needed this for any page that loaded lots of images, all of the above would significantly increase page-load time, and memory usage. Especially on a mobile browser, it would use more resources (hence more battery), than otherwise. So personally I wouldn't like to see this be the future. Maybe just as a fall back, but detection for that might be a little hard.

Re:BPG Image format by makewavesnotwar on Saturday December 06, 2014 @03:46PM (#8710139)
>> Does the javascript decoder download the images, or does the browser do that, then the javascript simply decode it?

Right now, it would appear that the with a hard reload of the demo: http://bellard.org/bpg/lena.html on chromium, the BPG images are initially loaded with the page, then the posts.js file scans through the page's images to find the ones who's src ends in '.bpg', then posts.js re-downloads the same files with ajax, which are then decoded to PNG files rendered in canvas tags with no identifying information.

The extra request to re-download images is unnecessary but easily removed to just process the data loaded with the initial page load.

>> Can CSS reference them without javascript changing the styles?

Not from what I can see. The images are being rendered to canvas elements without any identifying information. The decoder will need to be modified to add identifying id's or classes. This again is an easy fix.

>> Can they be cached locally if downloaded directly?

This is what I perceive to be an issue. Try downloading the image rendered to the 5kb bpg example... The image that is being rendered is a 427.5kb PNG and that's for a 512x512 image size.

PNGs aren't lossy... so any difference in file size is going to be the product of rendering size or how much the bpg compression has simplified the source image. ( I'm guessing the file size follows something like a logarithmic curve where it jumps initially based on rendered image dimensions and then approaches a limit as the compression approaches lossless. )

Because of the rendered out PNGs' large file size, I would expect that if you are rendering out large images or a lot of images, you would definitely use more resources than with comparable quality JPGs regardless of whether you cache the BPGs for rendering and you would indeed experience the drawbacks you mentioned in both memory and page-load time.

That being said, this is a cool idea, an incredible proof of concept and I'm very thankful to Fabrice for putting it out there.

Re:BPG Image format by cientifico on Tuesday December 16, 2014 @04:14AM (#8756393)
>> The extra request to re-download images is unnecessary but easily removed to just process the data loaded with the initial page load.

Are you sure you are not inspecting with the cache disabled. If the appropriate cache headers are applied, this shouldn't issue another request.

Re:BPG Image format by simcop2387 on Saturday December 06, 2014 @02:44AM (#8708661)
A quick glance makes it look like it grabs it by url in the decoder so I think it is doing another download. That said it's probably not too bad since the browser should cache the image also.
Re:BPG Image format by Cieplak on Friday December 05, 2014 @07:47PM (#8707867)
If you're curious how it works, untar http://bellard.org/bpg/libbpg-0.9.tar.gz and have a look at the post.js file.
Re:BPG Image format by akshatpradhan on Saturday December 06, 2014 @10:07AM (#8709316)
I'm a designer, can't read code, and I'm trying to see if I should evangelize this at work. Its better if you could communicate with us non-technical folk and post an answer that the previous guy asked so that we other designers can also understand.
Re:BPG Image format by k__ on Saturday December 06, 2014 @12:45PM (#8709677)
it waits till the page is loaded (window.onload)

grabs all image urls of a page

checks which have .bpg extensions

replaces all these .bpg img tags with canvas tags

loads all the images with Ajax and renders them into the canvas tags

Re:BPG Image format by unsigner on Saturday December 06, 2014 @02:40PM (#8709949)
If you're a designer, and don't understand the issues involved, you probably should refrain from evangelizing sub-1.0 versioned products.
Re:BPG Image format by akshatpradhan on Saturday December 06, 2014 @07:32PM (#8710749)
Sounds like a plan. I don't need to be an early adopter
Re:BPG Image format by wmf on Friday December 05, 2014 @06:48PM (#8707642)
Polyfills have been around for a while; this isn't the first one. e.g. http://webpjs.appspot.com/ http://badassjs.com/post/12035631618/broadway-an-h-264-decod...
Re:BPG Image format by akshatpradhan on Friday December 05, 2014 @11:04PM (#8708303)
If you want Designers to start using this, then we need a photoshop plugin, an illustrator plugin, a Sketch plugin, a pixelmator plugin. Make it easier for us to export images as a .BGP. If the images are truly smaller without affecting the current user experience of users using mostly modern web browsers, then we're more likely to pick up on using this.
Re:BPG Image format by krick on Saturday December 06, 2014 @10:49AM (#8709387)
No you don't. You export it as png or whatever lossless format you can and your job here is pretty much done. Then technical guys you are working with convert it or write a script to convert it automatically on upload/download on their website or do whatever they need to do to get lossy image for whatever purposes.

Still, to become truly widespread you need to have support in all kinds of software out there, "everything you need is js plugin" is unreasonable optimism in my opinion. And, anyway, decoding using js isn't fast enough to be one and only solution forever, you need to get to have browser and other software support sooner or later, and for that you need 1 standardized format, not "whatever your plugin supports" as thread-starter suggests.

Re:BPG Image format by SyneRyder on Saturday December 06, 2014 @05:22AM (#8708878)
For the Photoshop file-format plugin, someone should contract out to Toby Thain at Telegraphics who has written a bunch of file format plugins. Or optionally use his GPL'd source code as a starting point if you want to DIY:

http://www.telegraphics.com.au/sw/

Re:BPG Image format by woah on Saturday December 06, 2014 @12:23AM (#8708446)
This can all be handled by Gulp or Grunt and designers won't have to worry about it if someone on the team can code.
Re:BPG Image format by akshatpradhan on Saturday December 06, 2014 @12:34AM (#8708474)
What if I use this: http://getbootstrap.com/examples/starter-template/ and add an img tag with a src to a .bgp? Will it render when I refresh the browser? I see that the BPG images are decoded in your browser with a small Javascript decoder. So a JS file is referenced in the HTML, and everything will run ok when I refresh? That's the promise?
Re:BPG Image format by 178 on Saturday December 06, 2014 @04:36AM (#8708808)
Yes.
Re:BPG Image format by huuu on Saturday December 06, 2014 @04:20AM (#8708782)
The server could encode it. So the designer can still upload a known format.

The only problem I see for now is SEO. Ofcourse the title and alt attributes can give some context but the images wont get indexed

Re:BPG Image format by tambourine_man on Friday December 05, 2014 @07:06PM (#8707710)
Isn't there hardware support for JPEG decoding on most mobile devices? If so, I imagine it couldn't compete performance and battery life wise. I remember Mozilla did a software video decoder once in JavaScript.

Still, it is quite amazing.

Re:BPG Image format by TD-Linux on Friday December 05, 2014 @07:39PM (#8707841)
Some devices do have hardware JPEG decoding, however all mobile browsers do software JPEG decoding, often with the SIMD-accelerated libjpeg-turbo.

This is the software video decoder, by the way: https://github.com/brion/ogv.js

Re:BPG Image format by michaelmior on Saturday December 06, 2014 @01:06AM (#8708535)
That said, the JPEG decoding is still done with native code as opposed to interpreted JS.
Re:BPG Image format by mronge on Friday December 05, 2014 @08:34PM (#8708001)
How come all mobile browser uses software JPEG decoding? Is it because of the startup latency of the hardware decoder?
Re:BPG Image format by josephagoss on Friday December 05, 2014 @08:42PM (#8708031)
My guess is that the average mobile CPU speed makes decoding a minor time factor within the process of getting an image from server to the clients screen.

If this is the case, then putting in a hardware decoder would be a needless expense.

Re:BPG Image format by jlebar on Saturday December 06, 2014 @12:06AM (#8708421)
I used to own the jpeg decoder at Mozilla, and this was certainly the case last time I looked at it. Even without SIMD, JPEG decoding is pretty cheap compared to most of the things the browser does. I certainly wasn't clamoring for someone to burn JPEG into silicon; I had other things keeping me up at night.
Re:BPG Image format by acqq on Saturday December 06, 2014 @10:31AM (#8709358)
Strange: JPG is, when compressed, order of times smaller than uncompressed, so if the graphic card would accept the compressed image, the amount of used memory bandwidth can significantly decrease. I also believe that the graphic card can achieve more parallelisation and therefore handle much bigger JPG images, which we produce all the time with always bigger cameras.

I believe that some browsers actually keep in RAM all the images uncompressed, that can acually be the reason that makes the potential for optimizations less obvious.

Re:BPG Image format by jlebar on Saturday December 06, 2014 @01:29PM (#8709798)
> I also believe that the graphic card can achieve more parallelisation and therefore handle much bigger JPG images

Very large images are fairly rare on the web. In particular phones don't have giant displays, so it's usually a waste of bandwidth to send a huge picture to a phone as part of a webpage. And, speaking only for mobile Firefox at the time I worked on it, we had lots of bigger problems with large images than decoding speed. For example, Firefox would keep the whole decoded image in memory while it was onscreen, even if it was only displaying only part of the image or only a downsampled version of the image. If it's a giant image, the decoded image could use up a large fraction of the device's memory.

I'm also not aware of any major phones with have GPGPUs -- I'm not an expert in this stuff, but I think you'd need that to get any serious acceleration from JPEG decoding.

Re:BPG Image format by cubancigar11 on Saturday December 06, 2014 @11:48AM (#8709526)
Hardware is real-estate in ever compacting mobile landscape.
Re:BPG Image format by wolf550e on Sunday December 07, 2014 @10:55AM (#8712506)
When transistor size goes down, accelerators which are idle most of the time become cheaper. Your power budget doesn't allow you to run all the chip's parts at the same time anyway.

https://en.wikipedia.org/wiki/Dark_silicon

Re:BPG Image format by buymorechuck on Friday December 05, 2014 @11:53PM (#8708399)
Security. Malicious JPEG encodings could break hardware codec implementations.
Re:BPG Image format by panzi on Friday December 05, 2014 @10:27PM (#8708242)
Maybe it has something to do with the browsers displaying the images progressively as they are loaded. Maybe the hardware decoders don't support that? That's guessed.
Re:BPG Image format by leeoniya on Friday December 05, 2014 @07:11PM (#8707725)
this will definitely need to be hardware-supported for decoding. on my phone, the decode time far exceeds the time it would take to serve up a bigger jpg file.

the demos reminded me what browsing on dialup was like. in fact dialup was better cause at least the decoding/loading was progressive/incremental, which doesnt seem to be the case here. i assume it's just the way the decoder is implemented?

Re:BPG Image format by vidarh on Saturday December 06, 2014 @01:37AM (#8708592)
It just needs to be implemented natively. On the demo page the decoding is done in javascript.
Re:BPG Image format by expr- on Saturday December 06, 2014 @11:30AM (#8709478)
I decided to give it a try on a low-spec Android tablet, running latest version of Firefox. Got coloured horizontal stripes instead of a proper picture for every BPG example – and not just once; I was unable to view the images on the tablet.

Not quite production-ready, I think.

Re:BPG Image format by masklinn on Saturday December 06, 2014 @01:34PM (#8709810)
Similar issue with Firefox/Android, the Lena BPG images are completely scrambled to hell.

Safari/iOS and Chrome/Android worked with no issue. Desktop Firefox also worked.

Re:BPG Image format by dletozeun on Saturday December 06, 2014 @06:04AM (#8708943)
A native implementation like the JPEG decoder would be fine. The bundled JS decoder implementation is elegant but not efficient on mobile platform (stalling here for seconds on iPad 3 / iOS 8 / chrome while JPEG ones are displayed instantaneously)
Re:BPG Image format by 0x0 on Friday December 05, 2014 @07:54PM (#8707890)
Also unfortunately it seems to crash MobilrSafari something fierce when you start to zoom. :-/
Re:BPG Image format by sillysaurus3 on Friday December 05, 2014 @06:14PM (#8707497)
Problem is that you can't link to BPG images yet. Specifically, right click -> copy link location.

If only the rightclick menu could be customized by JS. Adding only a limited number of entries to the menu seems like it'd be okay.

Re:BPG Image format by rinon on Friday December 05, 2014 @06:20PM (#8707519)
With additional effort you can by including the proper JS. However, many sites would find this a benefit rather than a problem, since hotlinking takes away page-views.
Re:BPG Image format by xanderjanz on Friday December 05, 2014 @09:48PM (#8708169)
You wouldn't really have to change the right click menu. You could put an invisible html div over top the images, and give them the correct link, instead of the raw decompressed image data. So a user would think they are right clicking the image, when really they are right clicking our overlay.
Re:BPG Image format by billyhoffman on Saturday December 06, 2014 @11:35AM (#8709494)
Are you referring to this?

Google Animated doodle with JPEG and opacity

http://zoompf.com/blog/2012/04/how-do-google-animated-doodle...