IKImageBrowserView Thumbnail Problem - objective-c

I download IKImageBrowserView sample named "IKImageKit Demo" from Apple official website.
But I find a problem.
For example:
When I import images from folder named "A", then I delete an image.
Then I import other image (name as same as the deleted image), the thumbnail in
IKImageBrowser will not change.
How could I resolve this problem?? Thanks!
Video display: http://www.youtube.com/watch?v=f3Jue9wOdUI

I came across a reference that said the internal cache IKImageBrowserView uses looks up thumbnails by ImageUID. So if you change the ImageUID that your data source returns to be something other than just file name (maybe file name + file size), then it will be treated as a different image.

You should take a look at the IKImageBrowserItem Protocol's imageVersion method. If you need to let IKImageBrowserView know that a item has changed its image you can increment the imageVersion. This will force the view to update the cached image.

Update: Wow, old post. Looks like the documentation was updated a while after I had posted; as the other answers suggest, looks like you need to increment the image's imageVersion to update an image from cache.
After mulling over the problem for close to three hours (once I started, it was really bugging me, too!), I came to the sad conclusion that it's a bug in how IKImageKit handles images. IKImageBrowserView has a cache of images and thumbnails, and from whatever experimental data I have, I'm guessing that it just caches its images based on location on disk, and not on image data (so it can load the data lazily, I guess), so even if the actual image data can change, reloading the same file location will not update the image itself.
Of course, I could be completely wrong - which wouldn't surprise me, since there's literally no documentation on the issue, so I have nothing but results from Instruments and the app itself to guide me - but my advice to you is to ignore the issue for now, since there's nothing you can do about it, and possibly file the bug with Apple.
Of course, if anyone can introduce other evidence about this, please do! I'd love to know more about it.
Good luck!

you should want to imageVersion update or name the image of the path.
if you delete image with name "1.png" after you put image if it's name "1.png" the image browser view show the previous image so you should take care of image naming. or imageVersion method.

Related

iTextSharp.text.Image.GetInstance changes Request.MapPath

I've been stuck on this problem all night. I've looked everywhere and can't seem to find anything related to my exact problem. On our IIS server we have a page that creates a pdf. We put an image in the header of the created PDF. This had been working properly until last night when we updated some unrelated code on different pages. Now when we try to create the PDF we get an error that the image file doesn't exist. Here's the weird part, iTextSharp.text.Image.GetInstance is changing the path we send to it?
Here's the line of code
Dim oImage As iTextSharp.text.Image = iTextSharp.text.Image.GetInstance(Request.MapPath("~/images/" & sLogo))
If we output the results of Request.MapPath("~/images/" & sLogo) we receive
E:\Inetpub\sitename\images\logo.jpg
When we place it in in the iTextShart.text.Image.GetInstance() function our path output changes to
C:\Windows\SysWOW64\inetsrv\images\defaultlogo.jpg
You can see the logo itself changes too, it should be noted that we do use DefaultLogo.jpg in the case that a client doesn't use their own logo but all the ones i'm testing with do. The path E:\Inetpub\sitename\images does exist and logo.jpg does exist.
Here's the weirdest part, if i change the path from images to image
IE: iTextSharp.text.Image.GetInstance(Request.MapPath("~/image/" & sLogo))
the output will be
E:\Inetpub\sitename\image\logo.jpg
So i have no idea why images doesn't resolve.
Any help is greatly appreciated, and if this answer has been posted before and i just can't find it i'm very sorry, and if you could point me to that i would appreciate that as well.
I figured out my issue, and it's sheer stupidity on my part. The page we call to create the pdf had bad security on it. Basically we were looking for a session variable that didn't exist and redirected that page to a session time out notice. Removed that session check and it's working now!

Cocoa messes path up?

I'm trying to create an app that has an todays widget extension. This app should simply access a folder full of pictures, load them and draw them to the screen. One picture every hour. The widget should do the same, widget wise.
While loading an image in the main app and drawing it to the screen works flawlessly doing this:
NSString *tildePath = #"~/Documents/Adrian/Art/desertMovie.jpg";
NSString *path = [tildePath stringByExpandingTildeInPath];
_image = [[NSImage alloc] initWithContentsOfFile:path];
the extension completely messes up the path. It uses the same code as the main application but obscures the path completely.
From:
~/Documents/Adrian/Art/desertMovie.jpg
to:
/Users/Adrian/Library/Containers/ac.at.hulala.AK.ImageViewer2.ImageViewerWidget/Data/Documents/Adrian/Art/desertMovie.jpg
If I use a path without "~" the path stays the same but the image still doesn't get loaded.
Can someone tell my what I have to do that it accesses the same folder the main application does?
EDIT:
Archiving the app and exporting it seems to fix that problem. However I still would like to know how to make this working while developing.
EDIT2:
This is so weird! When working with the Todays Extension Widget a path like #"~/Pictures would lead to /Users/Me/Libraries/Containers/ac.at.ImageViewerWidget/Data/ like what the f***, why!?
When I force it to use the path #"/Users/Me/Documents/Pictures and run it the Memory Usage steadily increases until it reaches the limit and my system goes to hell. I really don't get that. I guess that the widget isn't finding any files so it tries to load the whole ssd. I guess. I really don't know whats the problem here.
Can someone please lead me into the light?
Not that xcode would tell you if something is wrong with your app. It will just allocate your whole memory and burn your cpu,
UNTIL,
you realize that the problem is caused by the lack of folder accessing permissions. Geezuz!
Add folder access permissions to your application if you want to access something!

Resizing in Dropzone.js?

Is there an example of the resize function for dropzone.js? I don't really understand how it works, it says:
"Resize is the function that gets called to create the resize information. It gets the file as first parameter and must return an object with srcX, srcY, srcWidth and srcHeight and the same for trg*. Those values are going to be used by ctx.drawImage()."
But I don't really get how to use it. So far I'm resizing the images on server-side, but I'd like to do it client-side and I think this might help. Any other solutions using dropzone.js if not this one?
I believe the built-in resize function in dropzoneJS is what is used to create the thumbnail, not resize the photo client-side, per se. There might be some way you could leverage it by setting the thumbnail dimensions to what you want to save to the server, and overwriting the file being saved with the thumbnail, but I'd have to hack about for a spell to offer you any code suggestions for that.

Previewg images via IKImage View

I need help ,I am pressed by time and I am blocked. Ihave a table view containing a directory's files (icon, name, size, date) . Tha table is filled via an arraycontroller. The table view just displays the image files and pdf files.When I select a row I want to preview the content in an IKImage view which isjust under the table. But I can't preview the content. Can you help me and give me some documentation , tutorials or commands on how to preview them and how to use ikimage view? I guess the ikimage view is the best solution. What do you think about that?
I guess that you have come up with the solution but a referral for others who might come here.
read apple example
its simple to start with.
In your case you can use - (void)setImage:(CGImageRef)image imageProperties:(NSDictionary *)metaData where your file properties can go in as dictionary object.
In the apple's example you can check out how to get CGImageRef from filepath, or you can use setImageWithURL.

How do you assign a default Image to the Blob object in Play framework?

I followed this nice article
http://www.lunatech-research.com/playframework-file-upload-blob
and have a perfectly working image upload solution
My questions is, if the user doesn't select any image, how do I assign a default image during save (probably stored in the server)?
if (!user.photo)
user.photo= ?;
user.save();
The one-hack that I can think of is upload the default image and see which UID "Play" stores in the /tmp directory and assign that above. Is there an elegant named* solution to this?
when I say named, I mean I want the code to look like (which means I know what I'm doing and I can also write elegant automated code if there are more than one picture)
user.photo= "images/default/male.jpg"
rather than (which means I'm just hacking and I can't extend it elegantly for a list of pictures)
user.photo= "c0109891-8c9f-4b8e-a533-62341e713a21"
Thanks in advance
The approach I have always taken is to not change the model for empty images, but instead do something in the view to show a default image, if the image does not exist. This I think is a better approach because your are corrupting your model for display purposes, which is bad practice (as you may want to be able to see all those who have not selected an image, for example).
To achieve this, in your view you can simply use the exists() method on the Blob field. The code would look like
#{if user.photo.exists()}
<img src="#{userPhoto(user.id)}">
#{/if}
#{else}
<img src="#{'public/images/defaultUserImage.jpg'}">
#{/else}
I have assumed in the above code that you are rendering the image using the action userPhoto as described in the Lunatech article.
I'd assume you can store the default image somewhere in your applications source folder and use
user.photo.set(new FileInputStream(photo), MimeTypes.getContentType(photo.getName()));
to save the data. Photo is just a File object, so you can get the reference of your default image and use it.