既然Instagram應用程序可以處理和張貼該應用程序內的非正方形圖像,我希望我可以使用相同的應用程序從我的應用程序發送非方形圖像到Instagram應用程序提供iPhone掛鉤我一直在使用(https://instagram.com/developer/iphone-hooks/?hl=en)。但是,它似乎仍然會將我的圖像裁剪成方形,而不是讓我選擇將它們展開爲非方形大小(與我在Instagram應用程序中直接從圖庫中加載非方形照片並且它可以讓我將其展開爲非方形原始尺寸)。任何人都有幸發送非方形圖像?我希望有一些調整,將使其工作。Instagram的iOS與非正方形圖像掛鉤
7
A
回答
0
我也希望他們可以在更新時使用非方形照片,但是您仍舊使用舊的方式發佈非方形照片......將它們遮住,以便與白色相符。
- (UIImage *)imageByScalingImage:(UIImage*)image proportionallyToSize:(CGSize)targetSize {
UIImage *sourceImage = image;
UIImage *newImage = nil;
CGSize imageSize = sourceImage.size;
CGFloat width = imageSize.width;
CGFloat height = imageSize.height;
CGFloat targetWidth = targetSize.width;
CGFloat targetHeight = targetSize.height;
CGFloat scaleFactor = 0.0;
CGFloat scaledWidth = targetWidth;
CGFloat scaledHeight = targetHeight;
CGPoint thumbnailPoint = CGPointMake(0.0,0.0);
if (CGSizeEqualToSize(imageSize, targetSize) == NO) {
CGFloat widthFactor = targetWidth/width;
CGFloat heightFactor = targetHeight/height;
if (widthFactor < heightFactor)
scaleFactor = widthFactor;
else
scaleFactor = heightFactor;
scaledWidth = width * scaleFactor;
scaledHeight = height * scaleFactor;
// center the image
if (widthFactor < heightFactor) {
thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5;
} else if (widthFactor > heightFactor) {
thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5;
}
}
// this is actually the interesting part:
UIGraphicsBeginImageContext(targetSize);
[(UIColor*)SHKCONFIG(instagramLetterBoxColor) set];
CGContextFillRect(UIGraphicsGetCurrentContext(), CGRectMake(0,0,targetSize.width,targetSize.height));
CGRect thumbnailRect = CGRectZero;
thumbnailRect.origin = thumbnailPoint;
thumbnailRect.size.width = scaledWidth;
thumbnailRect.size.height = scaledHeight;
[sourceImage drawInRect:thumbnailRect];
newImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
if(newImage == nil) NSLog(@"could not scale image");
return newImage ;
}
+0
我建議舉報一個bug,我做了;) – troppoli
相關問題
- 1. iOS:使用特殊字符的Instagram掛鉤
- 2. 使用掛鉤的Instagram視頻分享
- 3. Instagram的API非方形圖像不被返回$數據 - >圖像 - > standard_resolution
- 4. Instagram掛鉤預選媒體問題
- 5. Instagram iPhone掛鉤 - 未導出照片
- 6. 標籤上的圖像像Instagram的IOS
- 7. 掛鉤與DLL遊戲鉤
- 8. Bootstrap - 圖像庫中的掛鉤
- 9. Instagram更新至5.0。如何設置「InstagramCaption」程序與iPhone掛鉤
- 10. 如何將NSURLSession方法與theos掛鉤?
- 11. 試圖掛鉤Notepad.exe
- 12. ngCordova相機 - 採取Instagram的方形圖片(iOS)?
- 13. 在ios的instagram上共享圖像
- 14. 掛鉤或不掛鉤 - git
- 15. API無掛鉤掛鉤
- 16. 創建方法的操作掛鉤或遠程掛鉤
- 17. gitolite_admin掛鉤和鏡像
- 18. 無法將圖像標籤與docker和ansible掛鉤
- 19. 非正方形圖像的錯誤結果
- 20. 事件不掛鉤正確
- 21. 如何正確掛鉤WM_COMMAND
- 22. Drupal鉤更改與掛鉤驗證
- 23. Android的iOS MobileSubstrate風格的掛鉤?
- 24. 如何讓Instagram像方形尺寸的圖片
- 25. 非矩形圖像
- 26. 非矩形圖像
- 27. 掛鉤窗口掛鉤時不能正確繪製
- 28. Instagram的字體圖標顯示爲一個正方形
- 29. 掛鉤的電話狀態iOS
- 30. 在iOS上分享圖像到Instagram
我也在找這個。你測試了不同的比例嗎?它似乎在Instagram應用程序內,它裁剪了一些肖像圖片,所以也許我們必須找到正確的矩形進行裁剪? –
有趣的是,instagram應用程序本身似乎不允許你採取風景或肖像圖像。它從圖書館導入的唯一圖像允許這樣做。看起來這個新的「功能」只有一半。 – AndyRyan