Skip to content

Instantly share code, notes, and snippets.

@pixelrevision
pixelrevision / PXRImageSizeUtil.h
Created April 15, 2013 23:21
A image resizing utility for iOS
#import <Foundation/Foundation.h>
typedef enum {
PXRImageSizeUtilVerticalAlignTop,
PXRImageSizeUtilVerticalAlignBottom,
PXRImageSizeUtilVerticalAlignMiddle
}PXRImageSizeUtilVerticalAlign;
typedef enum {
PXRImageSizeUtilHorizontalAlignLeft,
@pixelrevision
pixelrevision / crop_images.py
Last active December 17, 2015 02:39
Image cropping with coordinates in file name
'''
Script to crop dead space in images and save out coordinates in the file name. Requires PIL to be installed:
http://www.pythonware.com/products/pil/
usage:
python crop_images.py path/to/input/dir path/to/output/dir
'''
from PIL import Image
from PIL import ImageOps
import os
import sys
@pixelrevision
pixelrevision / resize_android_images.py
Last active December 19, 2015 06:49
Process Android images
'''
requires imagemagick to be installed. http://www.imagemagick.org/script/index.php
'''
import os
import sys
import subprocess
import argparse
# defines the input we want to use. Change the directory name or the target DPI to set this.
inputDirName = "drawable-xhdpi"
@pixelrevision
pixelrevision / resize_ios_images.py
Last active December 21, 2015 11:39
Resize iOS images
'''
requires imagemagick to be installed. http://www.imagemagick.org/script/index.php
requires pngquant to be installed if using compression on pngs. http://pngquant.org/
'''
import os
import sys
import subprocess
import argparse
import shutil
import mimetypes
@pixelrevision
pixelrevision / excel_to_table.py
Last active December 28, 2015 05:59
Creates html tables from an excel doc
#!/usr/bin/python
import os
import shutil
import xlrd
import argparse
import xml.etree.ElementTree as elementTree
import xml.dom.minidom as minidom
def parseExcelDoc(xlsFile, outputFile, useTableHeader):
print xlsFile
@pixelrevision
pixelrevision / PXRPropSerializer.h
Created February 6, 2014 01:17
Property Serializer
#import <Foundation/Foundation.h>
#import <objc/runtime.h>
typedef enum {
PXRPropSerializerTypeUnknown,
PXRPropSerializerTypeFloat,
PXRPropSerializerTypeDouble,
PXRPropSerializerTypeInt,
PXRPropSerializerTypeClass,
PXRPropSerializerTypeBool
@pixelrevision
pixelrevision / PixelLevelCollision.js
Last active January 23, 2018 19:28
PixelLevelCollision.js
/*
Works with the alpha channel of an image to determine if there is collision with alpha
@parameter image - the image to check coordinate with.
@parameter sampling - (0.1-1.0) The percentage to downsample the image. Helps with performance and memory. Default 0.5
@parameter threshhold - (0.0-1.0) the threshhold to set the alpha for a hit. default 0.2
*/
var PixelLevelCollision = function(image, sampling, threshhold){
var self = this;
if(sampling === undefined){
#import <Foundation/Foundation.h>
@interface NSURLRequestFileInfo : NSObject
@property NSData *data;
@property NSString *name;
@property NSString *key;
+ (NSURLRequestFileInfo *)fileInfoWithData:(NSData *)data key:(NSString *)key andName:(NSString *)name;
@end
@interface NSURLRequest (FileAdditions)
@pixelrevision
pixelrevision / excel_to_json.py
Created May 24, 2016 19:35
spreadsheet to json
#!/usr/bin/python
import os
import argparse
import xlrd
import json
def create_json_object(args):
workbook = xlrd.open_workbook(args.input)
sheet = workbook.sheet_by_index(0)
json_array = []
@pixelrevision
pixelrevision / UIApplication+BuildInfo.swift
Created September 7, 2016 15:13
Adds strong typed build info to UIApplication
import Foundation
extension UIApplication {
var build: String {
return NSBundle.mainBundle().infoDictionary!["CFBundleVersion"] as! String
}
var version: String {
return NSBundle.mainBundle().infoDictionary!["CFBundleShortVersionString"] as! String