Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
squirreltown
Roku Guru

Re: Can Roku generate a JPG or PNG file?

"RokuMarkn" wrote:
Sending a 1.5 MB file should take the same amount of time, no matter what the file type is. I think the most important thing to know is the actual size in bytes of the result of GetPng, compared to the dimensions of the bitmap that went into it.

--Mark


Most of my captures from GetPNG() are less than 1.5mb ( 200k - 1.4mb). So, roughly the same amount of data.
Again, It's hard to see a byte array ( uncompressed text - about 3.7mb for 1280x720) taking the same amount of time as a .png. as a coincidence.
Kinetics Screensavers
0 Kudos
EnTerr
Roku Guru

Re: Can Roku generate a JPG or PNG file?

"squirreltown" wrote:
Most of my captures from GetPNG() are less than 1.5mb ( 200k - 1.4mb). So, roughly the same amount of data.
Again, It's hard to see a byte array ( uncompressed text - about 3.7mb for 1280x720) taking the same amount of time as a .png. as a coincidence.

Are you saying that the same PNG that was just uploaded to your NAS for 5 seconds - when you include EXACTLY the same file (under new name) in the .zip this time - suddenly takes 1 second to upload?! If so, see magic elves 🙂

Wait - have you discounted the compression time? I PS'd above, getPng() alone takes ~2.5sec with a sample HD image roScreen on Roku3 ...
0 Kudos
squirreltown
Roku Guru

Re: Can Roku generate a JPG or PNG file?

"squirreltown" wrote:

Sending a 1.5mb png from pkg:/ takes about 1.2 seconds for URL transfer to return successful. (Async Post From File)
Sending a 1.2 mb getpng() file from tmp:/ takes about 5-6 seconds for for the temp.rgba file to show on the NAS indicating the transfer is done.

It sounds like you're testing for completion in two different ways here. How long does it take for an AsyncPostFromFile to return success when you send the 1.2 MB getpng file?
And how long does it take for the file to show up on the NAS when you send a file from pkg:?
In your second case, if you're not looking at the AsyncPost result, you may just be measuring some lag in the NAS reporting that it has actually received the file after the transfer is done.

--Mark
Kinetics Screensavers
0 Kudos
RokuKC
Roku Employee
Roku Employee

Re: Can Roku generate a JPG or PNG file?

Various comments re. the above discussion 🙂

* yes, it doesn't surprise me that the time to convert to PNG + upload PNG is greater than the time to upload raw pixel data, at least for larger bitmap dimensions and/or on lower end hardware.

* the main intent of exposing this API is to allow using roBitmap composition to prepare a dynamic local image for use in the app UI, that can't be reasonably be achieved otherwise.

* definitely, the choice to use GetPNG should be done carefully. I would recommend it should not be used in cases where it would block the user interface significantly, other than possibly for a short time during program loading, if needed for one time preparation of dynamic assets. Of course if the use is for your own local development / test purposes, that doesn't need to be a consideration.

* feature request noted regarding the ability to control the compression vs. speed behavior. 🙂
0 Kudos
EnTerr
Roku Guru

Re: Can Roku generate a JPG or PNG file?

"RokuKC" wrote:
* feature request noted regarding the ability to control the compression vs. speed behavior. 🙂

That's a feature creep! Smiley LOL I was careful to avoid asking that. Because indeed
* the main intent of exposing this API is to allow using roBitmap composition to prepare a dynamic local image for use in the app UI, that can't be reasonably be achieved otherwise.

If it can be 2x as fast - it should. By default, no params. If it can only be 10% faster, never mind "improving" - this is good enough
0 Kudos
squirreltown
Roku Guru

Re: Can Roku generate a JPG or PNG file?

"EnTerr" wrote:
I PS'd above, getPng() alone takes ~2.5sec with a sample HD image roScreen on Roku3 ...


Similar (R3 4200)

1480 x 920 (mark is after file written to tmp)
time 982 size 438789
time 2217 size 1216033

1280 x 720
time 715 size 327119
time 2275 size 927638
Kinetics Screensavers
0 Kudos
RokuMarkn
Visitor

Re: Can Roku generate a JPG or PNG file?

Argh. Squirreltown, I'm sorry, I was trying to reply to your posting above and instead I edited it. Feel free to restore what you originally said.

--Mark
0 Kudos
squirreltown
Roku Guru

Re: Can Roku generate a JPG or PNG file?

"RokuMarkn" wrote:
Argh. Squirreltown, I'm sorry, I was trying to reply to your posting above and instead I edited it. Feel free to restore what you originally said.
"squirreltown" wrote:
"squirreltown" wrote:

Sending a 1.5mb png from pkg:/ takes about 1.2 seconds for URL transfer to return successful. (Async Post From File)
Sending a 1.2 mb getpng() file from tmp:/ takes about 5-6 seconds for for the temp.rgba file to show on the NAS indicating the transfer is done.

It sounds like you're testing for completion in two different ways here. How long does it take for an AsyncPostFromFile to return success when you send the 1.2 MB getpng file?
And how long does it take for the file to show up on the NAS when you send a file from pkg:?
In your second case, if you're not looking at the AsyncPost result, you may just be measuring some lag in the NAS reporting that it has actually received the file after the transfer is done.

--Mark
'

LOL! Who knows what I said! The reason i'm using two metrics is that I don't have the PHP code to receive the image file properly ( havn't found what i need on StackOverload) and URL transfer won't return until the getpng() or bytearray file is processed by the PHP file. You seem to be skeptical of what I'm saying but there is a real easy explanation that is sort of implied in RokuKC's answer and my experience here,- the GetPNG() file is being sent as text, not as an image file. This is why my PHP file still works by just changing jpg to png - it's still a stream, not an image file. Wrong?

$owner = $_GET['owner'];
$sizex = $_GET['sizew'];
$sizey = $_GET['sizeh'];
$in = fopen('php://input', 'r');
$out = fopen("$owner.rgba", 'w');
stream_copy_to_stream($in, $out);

exec("convert -size {$sizex}x{$sizey} -depth 8 -adaptive-resize 1920x1080 $owner.rgba $owner.png");
Kinetics Screensavers
0 Kudos
EnTerr
Roku Guru

Re: Can Roku generate a JPG or PNG file?

<sigh> troubleshooting @squirreltown should have been split in separate thread, unrelated.
RokuKC said no such thing.
And of course have to comment out `exec("convert -size ... ")` (ImageMagick?) line first before benchmarking!
How that even works when you give it a .png mis-labeled as .rgba? Either way, is unclean to include the conversion time.
"changing jpg to png"... what?!
0 Kudos
squirreltown
Roku Guru

Re: Can Roku generate a JPG or PNG file?

"EnTerr" wrote:
<sigh> troubleshooting @squirreltown should have been split in separate thread, unrelated.
RokuKC said no such thing.
And of course have to comment out `exec("convert -size ... ")` (ImageMagick?) line first before benchmarking!
I have no idea how that even works when you give it a .png mis-named as .rgba?
"changing jpg to png"... what?!



RokuKC - "yes, it doesn't surprise me that the time to convert to PNG + upload PNG is greater than the time to upload raw pixel data, at least for larger bitmap dimensions and/or on lower end hardware."
I'm sure that means something.

I have been careful to make my benchmarks separate from what the PHP file is doing, so I really don't know what you are complaining about. Separate Thread? That's the PHP file I've been using. It works, you probably know why, I certainly don't.
Kinetics Screensavers
0 Kudos
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.