From 18bb4ebb7f1114efc395cea67b3e964be073b076 Mon Sep 17 00:00:00 2001 From: Philipp Fehre Date: Thu, 24 Dec 2015 13:02:28 +0000 Subject: [PATCH] updating SDK version --- Classes/ComSideshowcoderJpgcompressorModule.m | 75 +++++++++---------- README.md | 4 +- jpgcompressor.xcodeproj/project.pbxproj | 4 +- manifest | 4 +- titanium.xcconfig | 4 +- 5 files changed, 46 insertions(+), 45 deletions(-) diff --git a/Classes/ComSideshowcoderJpgcompressorModule.m b/Classes/ComSideshowcoderJpgcompressorModule.m index 1419319..86b5fe3 100644 --- a/Classes/ComSideshowcoderJpgcompressorModule.m +++ b/Classes/ComSideshowcoderJpgcompressorModule.m @@ -1,9 +1,26 @@ /** - * Your Copyright Here + * Copyright (c) 2011, Philipp Fehre All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are permitted provided that the + * following conditions are met: + * + * Redistributions of source code must retain the above copyright notice, this list of conditions and the following + * disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following + * disclaimer in the documentation and/or other materials provided with the distribution. + + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * Appcelerator Titanium is Copyright (c) 2009-2010 by Appcelerator, Inc. * and licensed under the Apache Public License (version 2) - */ + **/ + #import "ComSideshowcoderJpgcompressorModule.h" #import "TiBase.h" #import "TiHost.h" @@ -29,28 +46,22 @@ -(NSString*)moduleId -(void)startup { - // this method is called when the module is first loaded // you *must* call the superclass [super startup]; - + NSLog(@"[INFO] %@ loaded",self); } -(void)shutdown:(id)sender { - // this method is called when the module is being unloaded - // typically this is during shutdown. make sure you don't do too - // much processing here or the app will be quit forceably - // you *must* call the superclass [super shutdown:sender]; } -#pragma mark Cleanup +#pragma mark Cleanup -(void)dealloc { - // release any resources that have been retained by the module [super dealloc]; } @@ -58,8 +69,6 @@ -(void)dealloc -(void)didReceiveMemoryWarning:(NSNotification*)notification { - // optionally release any resources that can be dynamically - // reloaded once memory is available - such as caches [super didReceiveMemoryWarning:notification]; } @@ -67,21 +76,10 @@ -(void)didReceiveMemoryWarning:(NSNotification*)notification -(void)_listenerAdded:(NSString *)type count:(int)count { - if (count == 1 && [type isEqualToString:@"my_event"]) - { - // the first (of potentially many) listener is being added - // for event named 'my_event' - } } -(void)_listenerRemoved:(NSString *)type count:(int)count { - if (count == 0 && [type isEqualToString:@"my_event"]) - { - // the last listener called for event named 'my_event' has - // been removed, we can optionally clean up any resources - // since no body is listening at this point for that event - } } #pragma Public APIs @@ -96,7 +94,7 @@ -(id)compress:(NSArray*)args // Get the output path if passed NSString *imgName = nil; NSMutableString *path = [NSMutableString string]; - NSLog(@"[DEBUG] Args lenght: %u", [args count]); + NSLog(@"[DEBUG] Args lenght: %u", [args count]); if ([args count] > 1) { ENSURE_ARG_COUNT(args, 2); imageData = [[args objectAtIndex:0] data]; @@ -106,25 +104,27 @@ -(id)compress:(NSArray*)args } else { imageData = [[args objectAtIndex:0] data]; } - + // DEBUG OUTPUT NSLog(@"[DEBUG] Received data size: %u Desired size: %@", [imageData length], cs); - + + UIImage* image = [[UIImage alloc] initWithCIImage:[[args objectAtIndex:0] image]]; // Check if data is larger than desired if ([imageData length] > [cs intValue]) { - // Calculate the needed compression and check if - CGFloat compressFactor = [cs floatValue] / [[NSNumber numberWithUnsignedInt:[imageData length]] floatValue]; + // Calculate the needed compression and check if + CGFloat compressFactor = [cs floatValue] / [[NSNumber numberWithUnsignedLong:[imageData length]] floatValue]; if(compressFactor < [cq floatValue]) { - NSLog(@"[DEBUG] Compress Factor: %f Worst Quality: %f", compressFactor, [cq floatValue]); + NSLog(@"[DEBUG] Compress Factor: %f Worst Quality: %f", compressFactor, [cq floatValue]); compressFactor = [cq floatValue]; } + if(imgName != nil){ // write to file and return path - [UIImageJPEGRepresentation([[args objectAtIndex:0] image], compressFactor) writeToFile:path atomically:YES]; + [UIImageJPEGRepresentation(image, compressFactor) writeToFile:path atomically:YES]; return path; } else { // return compressed image - NSData* compressedData = UIImageJPEGRepresentation([[args objectAtIndex:0] image], compressFactor); + NSData* compressedData = UIImageJPEGRepresentation(image, compressFactor); NSLog(@"[DEBUG] Compressed size: %u Compress Factor: %f", [compressedData length], compressFactor); return [[[TiBlob alloc] initWithData:compressedData mimetype:@"application/octet-stream"] autorelease]; } @@ -132,7 +132,7 @@ -(id)compress:(NSArray*)args // return the uncompressed image if(imgName != nil){ // write to file and return path - [UIImageJPEGRepresentation([[args objectAtIndex:0] image], 1.0) writeToFile:path atomically:YES]; + [UIImageJPEGRepresentation(image, 1.0) writeToFile:path atomically:YES]; return path; } else { // return uncompressed image @@ -145,7 +145,7 @@ -(id)scale:(id)args // Storage for the scale size CGSize newSize; // Get the values needed from the arguments - UIImage *image = [[args objectAtIndex:0] image]; + UIImage* image = [[UIImage alloc] initWithCIImage:[[args objectAtIndex:0] image]]; newSize.width = [[TiUtils numberFromObject:[args objectAtIndex:1]] floatValue]; newSize.height = [[TiUtils numberFromObject:[args objectAtIndex:2]] floatValue]; NSLog(@"[DBEUG] Scale size: %f x %f", newSize.width, newSize.height); @@ -160,21 +160,20 @@ -(id)scale:(id)args -(id)compressSize { - return [self valueForUndefinedKey:@"compressSize"]; + return [self valueForUndefinedKey:@"compressSize"]; } -(void)setCompressSize:(id)value { - [self replaceValue:[TiUtils numberFromObject:value] - forKey:@"compressSize" + [self replaceValue:[TiUtils numberFromObject:value] + forKey:@"compressSize" notification:NO]; } -(id)worstCompressQuality { - // when set return value else return 1 as it is 100% quality if ([self valueForUndefinedKey:@"worstCompressQuality"]) { - return[self valueForUndefinedKey:@"worstCompressQuality"]; + return [self valueForUndefinedKey:@"worstCompressQuality"]; } return [NSNumber numberWithInt:0]; } diff --git a/README.md b/README.md index 1bcdb08..db8d9c9 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,9 @@ See `example/app.js` and https://github.com/sideshowcoder/jpgcompressor/blob/mas Testing ------- -Run the example app and follow it's log see `example/app.js` for more details +Build the module via `python build.py` and install it `unzip -o +com.sideshowcoder.jpgcompressor-iphone-0.5.4.zip -d ~/Library/Application\ Support/Titanium/` + Setup ----- diff --git a/jpgcompressor.xcodeproj/project.pbxproj b/jpgcompressor.xcodeproj/project.pbxproj index 5d632f3..5f571af 100644 --- a/jpgcompressor.xcodeproj/project.pbxproj +++ b/jpgcompressor.xcodeproj/project.pbxproj @@ -256,7 +256,7 @@ OTHER_LDFLAGS = ""; PREBINDING = NO; SDKROOT = iphoneos; - VALID_ARCHS = "armv7 i386 x86_64 arm64"; + VALID_ARCHS = "i386 armv7 x86_64 arm64"; }; name = Debug; }; @@ -271,7 +271,7 @@ OTHER_LDFLAGS = ""; PREBINDING = NO; SDKROOT = iphoneos; - VALID_ARCHS = "armv7 i386 x86_64 arm64"; + VALID_ARCHS = "i386 armv7 x86_64 arm64"; }; name = Release; }; diff --git a/manifest b/manifest index 2ef96d4..ab2ff14 100644 --- a/manifest +++ b/manifest @@ -1,4 +1,4 @@ -version: 0.5.3 +version: 0.5.4 description: Compress JPEG Images using UIImageJPEGRepresentation, and scale using UIGraphicsBeginImageContext author: Philipp Fehre license: BSD @@ -10,5 +10,5 @@ name: jpgcompressor moduleid: com.sideshowcoder.jpgcompressor guid: ff873835-cf92-4d21-b2c0-0f577f0ce8f3 platform: iphone -minsdk: 3.5.0.GA +minsdk: 5.1.1.GA architectures: armv7 i386 x86_64 arm64 diff --git a/titanium.xcconfig b/titanium.xcconfig index 2b0b050..96c04aa 100644 --- a/titanium.xcconfig +++ b/titanium.xcconfig @@ -4,10 +4,10 @@ // OF YOUR TITANIUM SDK YOU'RE BUILDING FOR // // -TITANIUM_SDK_VERSION = 3.5.0.GA +TITANIUM_SDK_VERSION = 5.1.1.GA -// +// // THESE SHOULD BE OK GENERALLY AS-IS // TITANIUM_SDK = ~/Library/Application Support/Titanium/mobilesdk/osx/$(TITANIUM_SDK_VERSION)