이미지 크기를 줄이려면 임계 값 질문에 대한 대답과 이미지를 줄이는 방법을 사용하고 Apple에서 쿼리하지 않는 것이 좋습니다.
일부 배경
: 내 앱에서
, 나는 사용자에게 자동으로 방지하는 방법으로 E-메일 링 전에 1024까지 자신의 이미지를 확장하는 옵션을 제공 애플의 '당신이 당신의 이미지를 축소 하시겠습니까? ' 질문.
오랫동안이 스케일 제거가 충분하다고 생각했습니다. 그러나 그들의 이미지에 세부 묘사가 충분하다면 1024x768조차도 여전히 Apple의 쿼리를 실행할 수 있다는 것을 발견했습니다.
그래서 아래 코드는이 문제를 해결하는 방법입니다. getMinImgSizFlag가 TRUE 인 경우, 이미 elsewhere.automatically 1024으로의
//...convert the UIImage into NSData, as the email controller requires, using
// a default JPG compression value of 90%.
float jpgCompression = 0.9f;
imageAsNSData = UIImageJPEGRepresentation([self camImage], jpgCompression);
if ([gDB getMinImgSizFlag] == TRUE)
{
//...if we are here, the user has opted to pre emptively scale their
// image down to 1024x768 to avoid Apple's 'scale the image down?'
// query.
//
// if so, then we will do a bit more testing because even with
// the image scaled down, if it has a lot of fine detail, it may
// still exceed a critical size threashold and trigger the query.
//
// it's been empirically determined that the critical size threashold
// falls between 391K and 394K bytes.
//
// if we determine that the compressed image, at the default JPG
// compression, is still larger than the critical size threashold,
// then we will begin looping and increasing the JPG compression
// until the image size drops below 380K.
//
// the aproximately 10K between our limit, 380K, and Apple's
// critical size threashold allows for the possibility that Apple
// may be including the contribution of the E-Mail's text size into
// its threashold calculations.
while ([imageAsNSData length] > 380000)
{
jpgCompression -= 0.05f;
imageAsNSData = UIImageJPEGRepresentation([self camImage], jpgCompression);
}
}
을 이미지를 스케일 제거했습니다합니다. 필자는이 코드를 테스트 했으므로 이미지를 전자 메일로 보내기 전에 이미지 크기를 줄이려는 Apple의 실수를 피할 수 있습니다.
나는 어디에도 문서화되어 있지 않다고 생각합니다. 임계 값을 확인하려면 시행 착오를 사용해야합니다. 다른 버전의 iOS에서는 문턱 값이 다를 수 있습니다. 다시 말하지만, 이메일 축소 크기는 이메일 첨부 파일 크기의 제한으로 인해 발생할 가능성이 가장 높으며 iOS 버전에서는 변경되지 않았을 가능성이 큽니다. – rmaddy
나는'MFMailComposeViewController' 클래스 레퍼런스와 그들이 제공하는 샘플 코드를 샅샅이 훑어 보았고 어디서나 문서화 된 것을 찾을 수 없었다. 누구나 특정 파일 크기의 이미지 파일을 생성 할 수있는 사이트/애플리케이션을 알고 있습니까? @rmaddy가 제안한대로 흔적과 오류를 사용할 것입니다. 임계 값은 1 ~ 2MB 정도라고 생각합니다. 나는 관련 질문을 여기에서 물었다 : http://stackoverflow.com/questions/14996209/mfmailcompleviewcontroller-force-actual-size-on-image-attachment – rog
나는 나의 JPG 심상을 1024x768 또는 768x1024 및 대부분의 이 시간은 애플이 내 이미지를 더 확장 할 것인지 묻지 못하도록 막기에 충분하다. 그러나 내가 본 이미지가 그 안에 정밀한 세부 사항을 많이 가지고있을 때, 심지어 그것을 잘라내도 쿼리를 막지는 못한다는 것을 나는 알았다. 지금 메시지가 510KB이고 메시지를 보내고있는 메시지를보고있는 중입니다. 500KB가 한계인지 궁금하네요. – Gallymon