enzyme69 / blendersushi

Blender Sushi related scripts. Mostly about Sverchok, Geometry Nodes, Animation Nodes, and related Python scripts.
244 stars 33 forks source link

BSLIVE 0011 / USDZ and Watermarking Using QR Code #434

Open enzyme69 opened 6 years ago

enzyme69 commented 6 years ago
screen shot 2018-08-06 at 11 48 05 am screen shot 2018-08-06 at 11 47 20 am
enzyme69 commented 6 years ago

Making QR Code using Python of any version is actually easy enough using this PyQRCode module: https://pypi.org/project/PyQRCode/

You can output as SVG, PNG, etc.

You could in theory run this inside Blender and output into image. Make sure the module you install is using the same Python as the one inside Blender.

enzyme69 commented 6 years ago

Using SWIFT PLAYGROUND on XCode (MacOS)

screen shot 2018-08-06 at 12 42 03 pm
import Foundation
import UIKit
import PlaygroundSupport

//let data = "Hello World - Blender Sushi!".data(using: .utf8)!
//let data = "https://blendersushi.blogspot.com".data(using: .utf8)!
//let data = "https://maps.apple.com/?address=367 George Street, Sydney, Australia".data(using: .utf8)!

let data = "https://youtube.com/c/jimmygunawan".data(using: .utf8)!
//let data = "https://blendersushi.blogspot.com".data(using: .utf8)!

let filter = CIFilter(name: "CIQRCodeGenerator", parameters: ["inputMessage" : data, "inputCorrectionLevel":"L"])

//if let ciimage = filter?.outputImage { UIImage(ciImage: filter) }
let ciimage = filter!.outputImage!
let transform = CGAffineTransform(scaleX: 15.0, y: 15.0)
let image = ciimage.transformed(by: transform)
let img = UIImage(ciImage: image)

// saving out result

let path = playgroundSharedDataDirectory.appendingPathComponent("MyQR.PNG")
//let temp:CGImage = context.createCGImage(output, from: output.extent)!
//let image = UIImage(cgImage: temp)
//let blah = UIImage.pngData(img)

//try blah()?.write(to: path)

if let blah = img.pngData() {
    try? blah.write(to: path)
}

// View LIVE
PlaygroundPage.current.liveView = UIImageView(image: img)