Giphy / giphy-android-sdk

Home of the GIPHY SDK Android example app, along with Android SDK documentation, issue tracking, & release notes.
https://developers.giphy.com/
Mozilla Public License 2.0
94 stars 37 forks source link

Get Giphy Attributes( size,height, width etc)? #201

Closed muaviyaijaz123 closed 1 year ago

muaviyaijaz123 commented 1 year ago

Describe your question in detail.

Is there a way to get attributes of giphy like its size, height , width as it is needed in our project because we need to an object like this:

{ { original={ url=https: //media4.giphy.com/media/t3sZxY5zS5B0z5zMIz/giphy.gif?cid=c4b036757q6x64xyacgd15qkmqzply9ws1ky70zy5icwcsw2&ep=v1_gifs_search&rid=giphy.gif&ct=g, width=500, height=281, size=11741706, frames=167 } } }

ALexanderLonsky commented 1 year ago

Hey @muaviyaijaz123 , You can access all the media attributes through the Image model. To do so, you need to select the desired rendition: val image = media.imageWithRenditionType(RenditionType.original)

then you can get the values:

image?.let {
    val width = it.width
    val height = it.height
    val size = it.gifSize // or it.webPSize
    val frames = it.frames
}

P.S. Here you can read more about the renditions.