MPMediaItemArtwork imageWithSize: is somewhat misleading
| Originator: | steven.baranski | ||
| Number: | rdar://10052528 | Date Originated: | 8/31/2011 |
| Status: | Open | Resolved: | |
| Product: | iPad SDK | Product Version: | 5.x |
| Classification: | Bug | Reproducible: | Always |
31-Aug-2011 07:56 AM Steven Baranski: SUMMARY: When interacting with the iPod MPMusicPlayerController, the API for MPMediaItemArtwork states that imageWithSize: "Creates and returns a UIImage object of a specified size." This implies that the specified size can truly be any value, when in fact, only three different sizes are returned: 128x128, 320x320, and 768x768. It's easy enough to adjust the returned image via UIImageView or similar, but perhaps the API would be more clear if the user were required to pass in an enumeration value for small, medium, and large graphic assets, etc.? STEPS TO REPRODUCE: Instantiate an iPod player, identify an MPMediaItem with available cover art, and invoke the method with an array of sizes. Observe that in many cases, the sizes returned don't match that requested. EXPECTED RESULTS: The API suggests that the method will do the sizing for you, but it appears to pick the closest cover art size available. The 128x128, 320x320, and 768x768 appear to be the standard iTunes graphics collateral sizes. ACTUAL RESULTS: Specifying sizes lower than 128x128 (e.g., CGSizeMake(100,100)) round up to that size; sizes lower than 320x320 round up to that; and every other size returns an image with size 768x768. REGRESSION: (intentionally left blank) NOTES: Presumably this applies to the iPhone SDK too. Thank you! 10-Oct-2011 06:01 PM Steven Baranski: 'screenshot.png' was successfully uploaded 10-Oct-2011 06:01 PM Steven Baranski: Thank you for alerting me to the revisions. Although the results differ, they still do not seem to match what one might expect. The following are a list of a input sizes and the actual resulting sizes using the iOS 5 GM. * 75x75 => 88x88 * 88x88 => 88x88 * 89x89 => 128x128 * 128x128 => 128x128 * 129x129 => 600x600 * 280x280 => 600x600 * 600x600 => 600x600 * 601x601 => 600x600 So it would appear that the "threshold" sizes have changed from one release to another. The sizes observed when the issue was originally reported were: 128x128, 320x320, and 768x768. Now it appears that those sizes are 88x88, 128x128, and 600x600. I have attached an image from one of my apps (StereoMatic) to illustrate the side effects. In this screenshot, the cover art "frame" is 306x306, but the image shown is 600x600. Here is the code that evinces the results observed: MPMediaItemArtwork *coverArt = [song valueForProperty:MPMediaItemPropertyArtwork]; // BEFORE: either 128x128, 320x320, 768x768 | AFTER: 88x88, 128x128, 600x600 UIImage *albumArt = [coverArt imageWithSize:CGSizeMake(306.0f, 306.0f)]; // albumArt.size = 600x600 The following additional methods help reduce the size to achieve the results expected; UIImageView *artView = [[[UIImageView alloc] initWithImage:albumArt] autorelease]; CGRect artRect = [artView frame]; artRect.size = CGSizeMake(306.0f, 306.0f); [artView setFrame:artRect]; I did not create a sample project, but the AddMusic project in the Apple iOS Sample Code repository may be worth a look: [MainViewController handle_NowPlayingItemChanged:] I hope this information proves useful. Please let me know if you have any additional questions or comments. Thanks again!
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!