Skip to content

Instantly share code, notes, and snippets.

@anaglik
anaglik / videosConverter.rb
Last active August 29, 2015 14:02
Handy script for converting videos using HandBrakeCLI.
DIRECTORY = "/videos/"
Dir.foreach(DIRECTORY) { |file|
next if !file.end_with?(".mov")
new_file = file.sub(".mov",".mp4")
puts "converting #{file} into #{new_file} ... \n"
%x{HandBrakeCLI -Z HigherProfile --strict-anamorphic --crop "0:0:0:0" -i "#{DIRECTORY}#{file}" -o "#{DIRECTORY}#{new_file}" }
}
@anaglik
anaglik / gist:6055542
Last active January 5, 2018 10:57
Example of "CIMaskToAlpha" filter's usage.
CIContext *context = [CIContext contextWithOptions:nil];
UIImage *entryImage = [UIImage imageNamed:@"someImage.png"];
CIImage *image = [CIImage imageWithCGImage:[entryImage CGImage]];
CIFilter *filter = [CIFilter filterWithName:@"CIMaskToAlpha"];
[filter setValue:image forKey:kCIInputImageKey];
CIImage *result = [filter valueForKey:kCIOutputImageKey];
CGImageRef cgImage = [context createCGImage:result fromRect:[result extent]];
UIImage *newImage = [UIImage imageWithCGImage:cgImage scale:[entryImage scale] orientation:UIImageOrientationUp];