Jump to content

Get original format of the texture from picture-service.secondlife.com


You are about to reply to a thread that has been inactive for 61 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

45 minutes ago, Luke Rowley said:

Hi, not sure that I'm in the good category, sorry for that.

Anyway, I'm trying to get textures from SecondLife on my web server using https://picture-service.secondlife.com/UUID/320x240.jpg but it ruins the original format of the picture. Is there a way to:

  • Get a higher resolution?
  • Get a resolution of the original format of the image?

 

Thank you.

You can download the texture directly from the CDN. Does this help?

http://asset-cdn.glb.agni.lindenlab.com/?texture_id=UUID

  • Sad 1
Link to comment
Share on other sites

7 minutes ago, Luke Rowley said:

Just tried to access http://asset-cdn.glb.agni.lindenlab.com/?texture_id=a4214a17-527c-a525-094f-2831797304e9, I got a download, I renamed it to test.png but I'm unable to open it with the Windows Explorer. Did I miss something? (The UUID is a correct inworld texture)

Oh sorry, I forgot to explain that bit  :D

It's a JPEG2000 image.  The texture will be saved with the extension *.j2c.
Rename the extension to *.jp2.
The texture can then be opened in software that supports JPEG2000, for example Irfanview with the JPEG2000 plugin.
You can then convert to your chosen image format.

 

 

 

Edited by Whirly Fizzle
  • Like 1
Link to comment
Share on other sites

I have a feature on my web server(Not yet "production ready" because it is my local network) that acts as both a asset CDN mirror and converter to formats designed for consumption by web applications.

The way I do it is this: https://gist.github.com/FelixWolf/66e989a1eb1f7fff3be26219c2da561d

That code is in python and can download the texture and convert it to png/tga/jpg, as well as extract any comments(which is useful for figuring out who uploaded it, when it was uploaded, what the average color value is, and it's original size before getting resized).

The portion you want is where I use imagemagick to convert it from jpeg2000 to png or others:

proc = subprocess.Popen(['convert', 'j2c:-', 'png:-'],
    stdout=subprocess.PIPE,
    stdin=subprocess.PIPE
)
proc.stdin.write(Handle.read())
proc.stdin.close()
result = proc.stdout.read()
cHandle.write(result)
return (
    200,
    [
        ('Content-type','image/png'),
        ('Content-Disposition', 'inline; filename="{}.png"'.format(Key))
    ]+utilNeverExpireHeaders(),
    result
)

which is very much also possible in php (Also posting this because it is what I presume most people use). Probably a bug or two because it is untested and my php is rusty.

<?php
function handleTexture($handle){
    $pConvert = proc_open('convert j2c:- png:-', array(
        0 => array("pipe", "r"),
        1 => array("pipe", "w"),
        2 => array("pipe", "w")
    ), $pipes, "/tmp/", array());
    
    if(is_resource($pConvert)){
        //Write the content to the input pipe
        fwrite($pipes[0], stream_get_contents($handle));
        fclose($pipes[0]);
        
        //Read the result
        $result = stream_get_contents($pipes[1]);
        fclose($pipes[1]);
        
        //Read any errors
        error_log(stream_get_contents($pipes[2]));
        fclose($pipes[2]);
        
        //Store the status code
        $status = proc_close($pConvert);
        
        if($status === 0){ //Success
            return $result;
        }else{
            return False;
        }
    }
    return False;
}
?>

The important take away here is "convert j2c:- png:-" which means to run the convert program from imagemagick, accept a j2c as stdin(-) and output a png to stdout(-). It is EXTREMELY IMPORTANT that you specify a input format, otherwise you can become vulnerable to https://imagetragick.com.

If you don't want to output it to stream to further process it, just replace "png:-" with a output file like /tmp/image.png.

You can do all sorts of stuff with imagemagick as well, such as resizing if you want to do that: https://imagemagick.org/script/convert.php

However, a much better solution is to use libraries that embed it. For me, this works, because I am not doing anything complex and I went over the process spawn to make sure it isn't vulnerable.

PHP does support imagemagick, but I haven't used it: https://www.php.net/manual/en/book.imagick.php

Pretty sure there is a python binding library somewhere too.

Edited by Chaser Zaks
  • Like 2
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 61 days.

Please take a moment to consider if this thread is worth bumping.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...