mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-12-24 07:05:35 +00:00
Implement progressive JPEG for photos
This commit is contained in:
@@ -5,6 +5,9 @@ static_library(
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
deps = [
|
||||
"//submodules/MozjpegBinding:MozjpegBinding",
|
||||
],
|
||||
frameworks = [
|
||||
"$SDKROOT/System/Library/Frameworks/Foundation.framework",
|
||||
"$SDKROOT/System/Library/Frameworks/UIKit.framework",
|
||||
|
||||
@@ -4,8 +4,11 @@ swift_library(
|
||||
name = "ImageCompression",
|
||||
module_name = "ImageCompression",
|
||||
srcs = glob([
|
||||
"Sources/**/*.swift",
|
||||
"Sources/**/*.swift",
|
||||
]),
|
||||
deps = [
|
||||
"//submodules/MozjpegBinding:MozjpegBinding",
|
||||
],
|
||||
visibility = [
|
||||
"//visibility:public",
|
||||
],
|
||||
|
||||
@@ -1,8 +1,19 @@
|
||||
import Foundation
|
||||
import AVFoundation
|
||||
import UIKit
|
||||
import MozjpegBinding
|
||||
|
||||
public func extractImageExtraScans(_ data: Data) -> [Int] {
|
||||
return extractJPEGDataScans(data).map { item in
|
||||
return item.intValue
|
||||
}
|
||||
}
|
||||
|
||||
public func compressImageToJPEG(_ image: UIImage, quality: Float) -> Data? {
|
||||
if let result = compressJPEGData(image) {
|
||||
return result
|
||||
}
|
||||
|
||||
let data = NSMutableData()
|
||||
guard let destination = CGImageDestinationCreateWithData(data as CFMutableData, "public.jpeg" as CFString, 1, nil) else {
|
||||
return nil
|
||||
@@ -46,3 +57,7 @@ public func compressImage(_ image: UIImage, quality: Float) -> Data? {
|
||||
|
||||
return data as Data
|
||||
}
|
||||
|
||||
public func compressImageMiniThumbnail(_ image: UIImage) -> Data? {
|
||||
return compressMiniThumbnail(image)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user