I'm trying to retrieve a photo from fb doing this call:
/id_photo?fields=picture
I take the field "picture" from the response and that give me an URL from where i can download the image.
The problem is that the image have a really poor quality and no matter if i change the parameters height and weight the result is the same.
So how can i download a specific photo from facebook in a good quality? (I have the photo ID)
?fields=images should give you all different photo sizes there are.
(Using width and height modifiers should also work, in theory - but depending on how close or not the sizes you request are to what's available, it might not always return the desired result. I have found it better to get all images sizes, and then pick the most appropriate one out of those.)
Related
I have a mobile app which has a screen with list of small images (3x3 grid). Click on image takes user to detail screen, where user can see that image in original size. Now, problem is that, for now, on backend side i only store full sized images (which i know is bad), but when i retrieve images for list i would like to return thumbs for original sized images.
The question is - what is the recommended thumbnail size to return?
Consider that this is an iOS and Android app.
Thanks in advance!
It depends how big you want to show it to the user.
i personally prefer 256X256
I want to have the posting-a-photo usecase in my android app.
This is the scenario I have implemented:
1. User posts a photo.
2. On the client side I scale the photo* , compress it and send
it to the server.
3. I store the photo on the server.
4. Users, who can view the photo, fetch the photo from the server.
The problem with this approach is that it doesn't take into consideration
the different-screen-sizes problem.
Let's say user A posts a photo.
User B, which has a phone with a larger screen**, fetches the photo
from the server. The photo doesn't fit good in the environment
since it has fixed width and height determined by user A (scaling in step 2).
I cannot simply scale the photo and put it into user B's ImageView, because
I am risking to loose the aspect ratio of the photo.
One approach that comes to mind is to simply remove the step 2 from the scenario.
I send the photo to the server, and when a user tries to fetch it
I scale the image according to the user's screen size (which I receive as parameters in the fetch request).
The problem with this approach is that, on each request, I will have
to scale the photo on-the-fly and send it to the client.
Another problem is the efficiency of uploading a photo, because I don't scale the photo (before uploading it).
It takes much more time to upload a full 2MB (or even a 500KB) photo than to simply upload a scaled photo (~20KB).
What are my options?
Since I am relatively new to Android, chances are that I am missing something essential.
Cheers!
*I scale maintaining the aspect ratio.
** Sorry for the terminology, i don't know how and when to use high density/pixels correctly. :-)
I have own dedicated server with unlimited traffic and 4T HDD. So, basically what I do is:
User take a picture by phone
User upload image to the webserver
Using ImageMagick + mozjpeg 3 I resize image 3 times and save it with prefixes small_, medium_, large_ OR with prefixes pre size: 1024_, 640_...
Now, my app can find user's screen dimensions and load image by doing request for specified prefix.
My arguments for doing in this war are:
Free traffic
Big HDD
Fast user's internet speed
When upload in another thread, and show to user another activity, he doesn't feel the "long waiting time" for uploading large images.
You always can resize photo on device, from 10Mb to 2Mb, for example, and on server do other resizes.
Now about image ratio. There you cannot to do a lot. You must decide, what to do in case that user with large screen and own aspect ratio tries to load image that was uploaded by user with small screen and own aspect ratio.
The truth is that screen size doesn't matter. What is matter is a ratio. So, you can load image, put it in ImageView, and this will filled with black background if the image is "smaller". O r you can load large size of image, crop it and put it to the ImageView. Larger image is used only for better quality.
In my case, I always do crop images if I use it as preview. I think it's looks more beautiful. When user want to view full size image, I download full image and show it as is.
A good server that handles images should:
receive images at high-quality
save or cache the images in multiple sizes (small, medium, large)
serve images according to a size parameter (larger phones ask for the large image)
There are many solutions for this kind of server. Most of them resize the image on-the-fly and cache the result. The client tells the server what size it wants. One example is the image handling in Google Play. Go to the play webside and view the urls of the app-icons (example). They have a width parameter.
You can also think of a maximum dimension (like 2048px) and resize the image before upload only if needed.
The client that views the image needs to decide on what size it asks from the server or it can resize the image on the phone, instead of relying on the server. Do this if traffic is not an issue. Consider using Picasso or Glide to make things easier.
Regarding aspect ratio: The client that views the image should handle this. It should expect any aspect ratio and be prepared for it. Use android:scaleType on the ImageView and decide which scale type fits your scenario. Here are the scale types. If you don't want black lines and want to occupy as much as possible from the screen, use CENTER_CROP - but you might end up losing parts of the image.
In most apps the original aspect ratio in maintained and two black "stripes" are added if your screen doesn't match.
I think it's not possible to manage all screen ratios...
ImageView has android:scaleType attr that preserves aspect ration to be broken,
like fitCenter or centerInside
And also calculate size of fetched image and set view size by yourself.
I am working on an app whose splashscreen would be handled dynamically. Thing is, there is only one background image we can upload on the server, so on the server side I need to prepare this image to fit with the different kinds of devices there are.
I can't seem to find an accurate list of image resolutions (in px) that would cover more or less all the Android devices (resolution generally seem very low compared to what I have for iPhones for example, and usually don't include tablets).
Does anyone have this information so I could set the server to generate different resolutions from the unique picture I upload and then I could retrieve whatever fits with the device I am currently working on (by passing relevant information about the size)?
Thanks in advance.
i think you only need 1 image, the largest resolution your app would possibly show,
and then you can specify the ImageView's layout_width and layout_height to your preferrable size in dp (or i think it's fill_parent if it's a splash)
i think it will resize the image automatically
how do you fetch the image background by the way?
i've done the same thing, i put the largest resolution in server, fetch the image using UrlImageViewHelper and it resizes automatically just fine, in different layouts
so there is only one image you'll use for the splashscreen background?
i think the better approach is to just put the image in your package,9patch image would do good to support different screensizes
or, if you really insist to fetch it from the server (you have the same image with different resolutions),
-specify your preferable width and height programatically according to the screensize
-round it (because various screensizes might generate different sizes in pixel), and add the width and height to the image_url string (
(ex: http://myServer.com/images/myImage300x600.jpg, http://myServer.com/images/myImage500x800.jpg , etc)
-make sure your server have the desired image by name
but because of the variety of device screensizes, i think the image still have to resize itself so it can fill the container
From your side is it possible ?
1.) first get the device size and make the server call , pass device type/size/flag or some identifier.
2.) pass some identifier parameter from your side to server side which recognize your image according to the device.
3.) server side side set same more than one image.
4.) set the response according your device size.
How to display an image using a URL of a known jpg, png ..etc. File ?
I want an image , and I want it to be loaded from the internet from a particular website.
With that done,
I would like to make that image of an appropriate size...
Say I put the width as the same as screen_width (size)....What about the height ? I don't want to spoil the ratio of height/width of the original image...So is the height automatically set to account for the ratio ? or do I have to put in some value myself ...?
Plus, I want it to be zoomable.
To load images from website, you need to get the path from website server where the photo is stored. For image displaying put height as wrap_content mode so that the space will occupy as much as needed to display.
For this purpose you can use a Lazy Adapter. Here you can find a good example of it: https://stackoverflow.com/a/3068012/2436683. Maybe you can use it as a starting point.
I'm posting images ot wall. Tried 200x200. Result on wall is: 96x96.
But I saw images on other posts with bigger dimmensions.
Where are the limitations described?
Images with dimensions bigger than 96x96 in feed is photos that was uploaded by user, and not posts created by application.
Documentation is a bit poor on that but there is no hard limit for image dimensions but the image will be displayed in different sizes across different views (this was stated in comments to several bugs, and I cannot find the source right now).
This means that in feed image will be displayed one size and the Timeline may display bigger version if available, and some other views may use other dimensions as well. One rule exists (which is stated about images across different documentation pages: Share, OpenGraph Protocol, Feed Dialog)
The image must be at least 50px by 50px and have a maximum aspect ratio of 3:1
When you share a URL, the maximal size for a linked image is 90x90.