Display Image from URL iOS - ios

I am using SDWebImage to display an image from URL inside an UIIMageView.
The issue is that my picture is not displayed while it works fine with other pictures from other servers.
This is my implementation:
[imageView sd_setImageWithURL:[NSURL URLWithString:product.imagePath]
placeholderImage:[UIImage imageNamed:#"apple-iphone-6-128gb-gold.jpg"]];
It doesnt work with this image from this URL: http://www.swstelecom.fr/api/images/products/1111/614
but it works with this one:
http://4.bp.blogspot.com/_hN-RNLUCt5Q/TSra3nOGmuI/AAAAAAAACZM/57j1rMTbPPs/Beautiful+love+wallpaper+3.jpg
Can anyone tell me why it doesnt work with the first image URL and how can I make it work, without making changes on the server, Because I dont have any control on server implementation.
PS: the picture is displayed fine on browser, so I dont understand what is the real problem here.

First link requires a login and password.
The link should have ".jpg" or ".png" at the end of it.

Related

SDWebImage not updating image in cache

I am using SDWebImage library for handling image cache. I implemented one of its method to download image from server and populating data in tableView. Here is my code for downloading image and showing in tableViewCell
In cellForRowAtIndexPath, I did the following code
[cell.profileImageView sd_setImageWithURL:[NSURL URLWithString:url] placeholderImage:nil options:SDWebImageRefreshCached];
It works perfectly here. But when I updated image on server, the tableViewCell still shows the same image. The problem is ,its cache is not updating image. I searched with the same keywords and came across this question on StackOverflow. But couldn't resolve the issue. I also tried to clear memory and cache on viewDidDisappear
-(void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:YES];
[[SDImageCache sharedImageCache]clearMemory];
[[SDImageCache sharedImageCache]clearDisk];
}
But its not efficient way. Is there any other way to update the cache when image on server is updated ?
You can use SDWebImageRefreshCached option to refresh concrete image, however you never know if the image was changed on the server side. So it's only your decision should you use image cache or not and when your cache should be updated.
From SDWebImage docs :
If you don't control the image server you're using, you may not be able to change the URL when its content is updated. In such case, you may use the SDWebImageRefreshCached flag. This will slightly degrade the performance but will respect the HTTP caching control headers
[imageView sd_setImageWithURL:url
placeholderImage:[UIImage imageNamed:#"placeholder.png"]
options:SDWebImageRefreshCached];
It would defeat the purpose of Image Caching if you use this in all your code. Coz the image will be downloaded everytime. Instead you could :
If you manage the server, you could setup some flags in the DB to indicate the image has changed on the server.
Implement some logic to only use SDWebImageRefreshCached once in 2 days or something like that, and use the normal code all other times.
You could also clear the entire cache once in a while to force a refresh, if that's feasible.

Load image from image url to show animation in UIImageview

I m getting more than 200 image url from web service and i am converting image url to UIImage array and showing animation in UIImageView and its crashing in device and its working fine in simulator? Can you plz provide any solution for this issue.
I think you should handle this job by using the native API:
[UIImage +animatedImageWithImages:(NSArray *)images duration:(NSTimeInterval)duration]

How to get user profile Image in big size from Twitter timeline object in iOS

I use twitter API fetchTimelineForUser:(NSString *)username to fetch tweets timeline. The size of user profile image in this object is normal. But I need a bigger size image.
How can I accomplish this?
BTW, I don't want to fetch the user object from twitter.
Thanks.
In profile image url you are getting _normal, appended with the image name like http://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3_normal.png
To get actual image remove _normal. It will be http://pbs.twimg.com/profile_images/2284174872/7df3h38zabcvjylnyfe3.png
You can see profile_image_url and profile_image_url_https in user object, normal sized image is mostly 48px - 48px. By modifying the url you can get larger image.
For more info please see this link.
Hope this helps.. :)

Adding "stretchable" images to and image selected from gallery

Im trying to make an app for planning out where you want to put "shelves" on a wall (sounds strange i know ;) )
i have got it so the image is picked from the UIImagePickerController then loaded in a new ViewController i also have a button at the bottom of the ViewController that i want to open a list of images to select from that once selected the user can move around then stretch the required size if they don't like, delete and once they are happy i want my second button to save the image and put it into an email ready for sending.
I have looked at a few ways but none of them seem to be "adequate" would be so grateful anyone could suggest any ways or even help me with some code, I'm very new to this and this is my first app.
Im not too sure on the code you'd need to see as none of what is written yet is relevant to this part of the app
This is a 2 part so the first is, what way do i go about it?, the second is what code?
Thanks
-(UIImage *)GetStreachableImage
{
UIImage *takephotoButtonImagenormal = [UIImage imageNamed:CHOOSE_TAKE_NORMAL_IMAGE];
UIImage *strechableButtonImageNormal1 = [takephotoButtonImagenormal stretchableImageWithLeftCapWidth:takephotoButtonImagenormal.size.width/2 topCapHeight:takephotoButtonImagenormal.size.height/2];
takephotoButtonImagenormal=nil;
return strechableButtonImageNormal1;
}
try this

SDImageCache not working

I am encountering a very strange issue in my application.
I have used SDWebImage in the application, to download the images to cache, when network present and then retrieve the images from the cache, when absent.
The SDWebImage works perfectly in case of UITableViews. One can even see the stored/cached image files in the iPhone Simulator folder.
And then theres this one piece of code, that is troubling me.
I am displaying a simple imageview, and caching the image from the network.
The image is displayed properly, when network is present.
But in case of no connectivity, nothing is displayed.
Am assuming, that the caching is not taking place.
Lines of code
dispatch_async(dispatch_get_main_queue(), ^{
[im setImageWithURL:[NSURL URLWithString:[[NSString stringWithFormat:#"%#%#",kImgaePath,[[marrresultingArraySet objectAtIndex:0] objectAtIndex:kIndex_RecipeImage_Local]] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]] placeholderImage:[UIImage imageNamed:#"no_imagepng.jpg"]];});

Resources