-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #9 from link-u/fix/odd-dimensions-and-color-matrix
Handle images with odd dimensions and fix color matrix, and add CI to check decoding functions
- Loading branch information
Showing
7 changed files
with
417 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: Check the decoded images. | ||
|
||
on: [push] | ||
|
||
jobs: | ||
build: | ||
runs-on: macos-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Build CLI tool | ||
shell: bash | ||
run: | | ||
set -ex | ||
cd Example | ||
pod install --repo-update | ||
xcrun xcodebuild \ | ||
-workspace SDWebImageAVIFCoder.xcworkspace \ | ||
-scheme "SDWebImageAVIFCoder_Example CLI" \ | ||
-archivePath ./CLI \ | ||
archive | ||
- name: Clone test images | ||
shell: bash | ||
run: | | ||
set -ex | ||
git clone https://github.com/link-u/avif-sample-images.git | ||
- name: Decode all AVIF images | ||
shell: bash | ||
run: | | ||
set -ex | ||
cd avif-sample-images | ||
mkdir decoded | ||
CMD="../Example/CLI.xcarchive/Products/usr/local/bin/SDWebImageAVIFCoder_Example CLI" | ||
for file in $(find . -name \*.avif); do | ||
file=$(basename ${file}) | ||
"${CMD}" "${file}" "./decoded/${file}.png" | ||
done | ||
- name: Install imagemagick to compare images. | ||
shell: bash | ||
run: brew install imagemagick | ||
- name: Compare images | ||
shell: bash | ||
run: | | ||
set -ex | ||
cd avif-sample-images | ||
for file in $(find . -name \*.avif); do | ||
file=$(basename ${file}) | ||
if (echo ${file} | grep "\(monochrome\|crop\|rotate\|mirror\)"); then | ||
# FIXME(ledyba-z): Check them. | ||
echo "Ignore: ${file}" | ||
continue | ||
else | ||
orig=$(cat Makefile | grep "^${file}" | sed "s/^${file}: \(.*\)$/\1/") | ||
score=$(compare -metric PSNR "${orig}" "decoded/${file}.png" NULL: 2>&1 || true) | ||
echo " * ${file}: ${score}" | ||
if test $(echo "${score} >= 35.0" | bc -l) -eq 0; then | ||
exit -1 | ||
fi | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
78 changes: 78 additions & 0 deletions
78
...bImageAVIFCoder.xcodeproj/xcshareddata/xcschemes/SDWebImageAVIFCoder_Example CLI.xcscheme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<Scheme | ||
LastUpgradeVersion = "1130" | ||
version = "1.3"> | ||
<BuildAction | ||
parallelizeBuildables = "YES" | ||
buildImplicitDependencies = "YES"> | ||
<BuildActionEntries> | ||
<BuildActionEntry | ||
buildForTesting = "YES" | ||
buildForRunning = "YES" | ||
buildForProfiling = "YES" | ||
buildForArchiving = "YES" | ||
buildForAnalyzing = "YES"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "6D37313D23E88F6B007F654B" | ||
BuildableName = "SDWebImageAVIFCoder_Example CLI" | ||
BlueprintName = "SDWebImageAVIFCoder_Example CLI" | ||
ReferencedContainer = "container:SDWebImageAVIFCoder.xcodeproj"> | ||
</BuildableReference> | ||
</BuildActionEntry> | ||
</BuildActionEntries> | ||
</BuildAction> | ||
<TestAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
shouldUseLaunchSchemeArgsEnv = "YES"> | ||
<Testables> | ||
</Testables> | ||
</TestAction> | ||
<LaunchAction | ||
buildConfiguration = "Debug" | ||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" | ||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" | ||
launchStyle = "0" | ||
useCustomWorkingDirectory = "NO" | ||
ignoresPersistentStateOnLaunch = "NO" | ||
debugDocumentVersioning = "YES" | ||
debugServiceExtension = "internal" | ||
allowLocationSimulation = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "6D37313D23E88F6B007F654B" | ||
BuildableName = "SDWebImageAVIFCoder_Example CLI" | ||
BlueprintName = "SDWebImageAVIFCoder_Example CLI" | ||
ReferencedContainer = "container:SDWebImageAVIFCoder.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</LaunchAction> | ||
<ProfileAction | ||
buildConfiguration = "Release" | ||
shouldUseLaunchSchemeArgsEnv = "YES" | ||
savedToolIdentifier = "" | ||
useCustomWorkingDirectory = "NO" | ||
debugDocumentVersioning = "YES"> | ||
<BuildableProductRunnable | ||
runnableDebuggingMode = "0"> | ||
<BuildableReference | ||
BuildableIdentifier = "primary" | ||
BlueprintIdentifier = "6D37313D23E88F6B007F654B" | ||
BuildableName = "SDWebImageAVIFCoder_Example CLI" | ||
BlueprintName = "SDWebImageAVIFCoder_Example CLI" | ||
ReferencedContainer = "container:SDWebImageAVIFCoder.xcodeproj"> | ||
</BuildableReference> | ||
</BuildableProductRunnable> | ||
</ProfileAction> | ||
<AnalyzeAction | ||
buildConfiguration = "Debug"> | ||
</AnalyzeAction> | ||
<ArchiveAction | ||
buildConfiguration = "Release" | ||
revealArchiveInOrganizer = "YES"> | ||
</ArchiveAction> | ||
</Scheme> |
5 changes: 5 additions & 0 deletions
5
Example/SDWebImageAVIFCoder_Example CLI/SDWebImageAVIFCoder_Example CLI.entitlements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict/> | ||
</plist> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// | ||
// main.m | ||
// SDWebImageAVIFCoder_Example CLI | ||
// | ||
// Created by psi on 2020/02/04. | ||
// Copyright © 2020 [email protected]. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <SDWebImage/SDWebImage.h> | ||
#import <SDWebImageAVIFCoder/SDImageAVIFCoder.h> | ||
|
||
int main(int argc, const char * argv[]) { | ||
if(argc != 3) { | ||
fprintf(stderr, "usage: %s <inputPath> <outputPath>\n", argv[0]); | ||
return -1; | ||
} | ||
@autoreleasepool { | ||
NSString* inputPath = [NSString stringWithUTF8String: argv[1]]; | ||
NSString* outputPath = [NSString stringWithUTF8String: argv[2]]; | ||
NSData* data = [[NSData alloc] initWithContentsOfFile: inputPath]; | ||
SDImageAVIFCoder* const coder = [SDImageAVIFCoder sharedCoder]; | ||
UIImage* img = [coder decodedImageWithData: data options:nil]; | ||
|
||
CGImageRef cgRef = [img CGImageForProposedRect:nil context:nil hints:nil]; | ||
NSBitmapImageRep *newRep = [[NSBitmapImageRep alloc] initWithCGImage:cgRef]; | ||
[newRep setSize:[img size]]; // if you want the same resolution | ||
NSDictionary *prop = [[NSDictionary alloc] init]; | ||
NSData* pngData = [newRep representationUsingType:NSBitmapImageFileTypePNG properties: prop]; | ||
[pngData writeToFile:outputPath atomically:YES]; | ||
} | ||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters