generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: how do i get the thumbnail image of a model

Previous Thread :: Next Thread 
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
29 Jul 2013 08:34 PM
im gonna need it for new icons for my new game
Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
29 Jul 2013 09:01 PM
I think you would have to upload it as a decal.
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
29 Jul 2013 09:09 PM
    local baseUrl = game:GetService("ContentProvider").BaseUrl;
    local assetUrl = "thumbs/asset.ashx?assetId=%d&x=%d&y=%d&format=png";
    local function getAssetThumbnail(assetId, x, y)
        return (baseUrl .. assetUrl):format(assetId, x, y);
    end
Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
29 Jul 2013 09:09 PM
...

nevermind
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
29 Jul 2013 09:13 PM
thank you blocco! :D
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
29 Jul 2013 09:14 PM
but uhh... how do i use it?
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
29 Jul 2013 09:15 PM
    local baseUrl = game:GetService("ContentProvider").BaseUrl;
    local assetThumbnailUrl = "thumbs/asset.ashx?assetId=%d&x=%d&y=%d&format=png";

    local thumbnailTypes = {
        SmallSquare = {64, 64},
        MediumSquare = {200, 200},
        LargeSquare = {420, 420},
        Rectangle = {420, 230}
    }

    local function getAssetThumbnail(assetId, thumbnailType)
        return (baseUrl .. assetThumbnailUrl):format(assetId, thumbnailTypes[thumbnailType] or {64, 64});
    end

    print(getAssetThumbnail(1818, "SmallSquare"))

I cleaned it up a bit, added some predefined thumbnail types
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
29 Jul 2013 09:16 PM
I really appreciate this, but I still can't figure out how I'm supposed to tell it which model to actually show.
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
29 Jul 2013 09:18 PM
sorry... I messed up, one sec

    local baseUrl = game:GetService("ContentProvider").BaseUrl;
    local assetThumbnailUrl = "thumbs/asset.ashx?assetId=%d&x=%d&y=%d&format=png";

    local thumbnailTypes = {
        SmallSquare = {64, 64},
        MediumSquare = {200, 200},
        LargeSquare = {420, 420},
        Rectangle = {420, 230}
    }

    local function getAssetThumbnail(assetId, thumbnailType)
        if type(thumbnailType) == "table" then
            return (baseUrl .. assetThumbnailUrl):format(assetId, unpack(thumbnailType));
        elseif type(thumbnailType) == "string" then
            return (baseUrl .. assetThumbnailUrl):format(assetId, unpack(thumbnailTypes[thumbnailType]));
        end
        return (baseUrl .. assetThumbnailUrl):format(0, 64, 64); -- broken asset picture
    end

    print(getAssetThumbnail(1818, "SmallSquare"))

Now to test it :D
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
29 Jul 2013 09:19 PM
It returns the thumbnail url for you to put in an imagelabel or imagebutton or decal to show an asset
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
29 Jul 2013 09:20 PM
but how do i tell the script which model it's supposed to show? D:
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
29 Jul 2013 09:22 PM
To use, put the following at the top of your script:

    local baseUrl = game:GetService("ContentProvider").BaseUrl;
    local assetThumbnailUrl = "thumbs/asset.ashx?assetId=%d&x=%d&y=%d&format=png";

    local thumbnailTypes = {
        SmallSquare = {64, 64},
        MediumSquare = {200, 200},
        LargeSquare = {420, 420},
        Rectangle = {420, 230}
    }

    local function getAssetThumbnail(assetId, thumbnailType)
        if type(thumbnailType) == "table" then
            return (baseUrl .. assetThumbnailUrl):format(assetId, unpack(thumbnailType));
        elseif type(thumbnailType) == "string" then
            return (baseUrl .. assetThumbnailUrl):format(assetId, unpack(thumbnailTypes[thumbnailType]));
        end
        return (baseUrl .. assetThumbnailUrl):format(0, 64, 64); -- broken asset picture
    end

And when you want to get the thumbnail url, simply use the value returned by `getAssetThumbnail(assetId, thumbnailType)`. `assetId` is your assetId. `thumbnailType` can be either "SmallSquare", "MediumSquare", "LargeSquare" or "Rectangle". For experienced users, you can give it a table with two elements which will give you a custom image size.
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
29 Jul 2013 09:24 PM
This is what i get

http://www.roblox.com/thumbs/asset.ashx?assetId=1818&x=64&y=64&format=png

do i replace "assetid" with the nubers from the website?
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
29 Jul 2013 09:28 PM
Yes
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
29 Jul 2013 09:31 PM
i put this in the decal

http://www.roblox.com/thumbs/asset.ashx?118661602=1818&x=64&y=64&format=png

the numbers came from the website for my ghost academy in my models, and all i got was a big grey X
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
29 Jul 2013 09:31 PM
Oh, and you may want to preload the asset first so that you don't get a grey R
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
29 Jul 2013 09:32 PM
i put THIS

http://www.roblox.com/thumbs/asset.ashx?assetid=118661602&x=64&y=64&format=png

and i got a big grey roblox logo instead :/
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
29 Jul 2013 09:32 PM
how do i preload? o.o i thought stuff only started loading when the game started O_o
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
29 Jul 2013 09:37 PM
Okay, it turns out you cannot escape the grey R like that... I just extensively tested. I have no solution for the grey R. Cross your fingers and hope for the best, I guess :P

Oh, and xiao you may want to use "LargeSquare" if you want better resolution
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
29 Jul 2013 09:41 PM
if there's no way to get around this, then whats the point of roblox letting players use it?
Report Abuse
blocco is not online. blocco
Joined: 14 Aug 2008
Total Posts: 29474
29 Jul 2013 09:42 PM
We're not *supposed* to use it, but it's there, so I used it
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
29 Jul 2013 09:46 PM
ok, so how am i supposed to make hairstyle icons without taking screenshots? :/
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
29 Jul 2013 09:54 PM
I guess I just won't use thumbnails :/ That's gonna make a lot of people mad when they go to decide their character's hairstyles >.<
Report Abuse
xiaoxiao181 is not online. xiaoxiao181
Joined: 14 Aug 2008
Total Posts: 5882
29 Jul 2013 10:54 PM
i figured it out! :D HWAHAHAHAHAHA

http://www.roblox.com/Game/Tools/ThumbnailAsset.ashx?aid=118656773&fmt=png&wd=420&ht=420
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image