[CIPDF417BarcodeGenerator]PDF417バーコードを作成する
基本はQRと同じ
値は仕様を参照
| 固定リンク
基本はQRと同じ
値は仕様を参照
| 固定リンク
基本はQRコードと同じ
| 固定リンク
webViewの基本構造はこちらを使用しています。
https://macscripter.net/viewtopic.php?pid=209146
| 固定リンク
api.qrserver.comのAPIを利用します
| 固定リンク
リンク先がこの画面のQRバーコードを生成します
| 固定リンク
行番号 | ソース |
---|---|
001 | #!/usr/bin/env osascript |
002 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
003 | # |
004 | # |
005 | #com.cocolog-nifty.quicktimer.icefloe |
006 | ----+----1----+----2----+-----3----+----4----+----5----+----6----+----7 |
007 | ##自分環境がos12なので2.8にしているだけです |
008 | use AppleScript version "2.8" |
009 | use framework "Foundation" |
010 | use framework "CoreImage" |
011 | use scripting additions |
012 | |
013 | property objMe : a reference to current application |
014 | property objNSString : a reference to objMe's NSString |
015 | set objFileManager to objMe's NSFileManager's defaultManager() |
016 | |
017 | set theURL to "" |
018 | set ocidNSInlineData to "" |
019 | set ocidNSBitmapImagePadRep to "" |
020 | |
021 | |
022 | ###set strLogFile to "/tmp/Geo2Qr4.txt" |
023 | |
024 | tell application "System Events" |
025 | launch |
026 | end tell |
027 | (* |
028 | tell application "System Events" |
029 | tell application process "Maps" |
030 | keystroke "C" using {command down} |
031 | end tell |
032 | end tell |
033 | |
034 | tell application "System Events" |
035 | keystroke "c" using {command down} |
036 | end tell |
037 | *) |
038 | try |
039 | tell application "System Events" |
040 | tell process "Maps" |
041 | get every menu bar |
042 | tell menu bar 1 |
043 | get every menu bar item |
044 | tell menu bar item "編集" |
045 | get every menu bar item |
046 | tell menu "編集" |
047 | get every menu item |
048 | tell menu item "リンクをコピー" |
049 | click |
050 | end tell |
051 | end tell |
052 | end tell |
053 | end tell |
054 | end tell |
055 | end tell |
056 | on error |
057 | tell application "System Events" |
058 | tell process "Maps" |
059 | get every menu bar |
060 | tell menu bar 1 |
061 | get every menu bar item |
062 | tell menu bar item "編集" |
063 | get every menu bar item |
064 | tell menu "編集" |
065 | get every menu item |
066 | tell menu item "コピー" |
067 | click |
068 | end tell |
069 | end tell |
070 | end tell |
071 | end tell |
072 | end tell |
073 | end tell |
074 | end try |
075 | |
076 | (* |
077 | tell application "System Events" |
078 | tell process "Maps" |
079 | tell menu bar 1 |
080 | tell menu bar item "Edit" |
081 | tell menu "Edit" |
082 | click menu item "Copy Link" |
083 | end tell |
084 | end tell |
085 | end tell |
086 | end tell |
087 | end tell |
088 | *) |
089 | |
090 | |
091 | tell application "Finder" |
092 | set theURL to (the clipboard) as text |
093 | end tell |
094 | delay 0.5 |
095 | |
096 | |
097 | try |
098 | set objAns to (display alert "どちら用のQRコードを作成しますか?" message "iOS用AppleMapのQRコードを作成する OR 一般的なQRコードを作成する" default button 1 buttons {"AppleMap用", "GoogleMap用", "汎用"}) |
099 | on error |
100 | log "エラーしました" |
101 | return |
102 | end try |
103 | |
104 | |
105 | set objResponse to (button returned of objAns) as text |
106 | |
107 | set theURL to theURL as text |
108 | |
109 | |
110 | ### |
111 | ###do shell script "echo \"" & theURL & "\" >> " & strLogFile & "" |
112 | #### |
113 | |
114 | ######################### |
115 | ####URLの整形 |
116 | set AppleScript's text item delimiters to "ll=" |
117 | set listUrl to every text item of theURL as list |
118 | set AppleScript's text item delimiters to "" |
119 | |
120 | set strSubURL to text item 2 of listUrl as text |
121 | |
122 | set AppleScript's text item delimiters to "&" |
123 | set listSubURL to every text item of strSubURL as list |
124 | set AppleScript's text item delimiters to "" |
125 | |
126 | set strLL to text item 1 of listSubURL as text |
127 | |
128 | set AppleScript's text item delimiters to "," |
129 | set listLL to every text item of strLL as list |
130 | set AppleScript's text item delimiters to "" |
131 | |
132 | set theLatitude to (item 1 of listLL) as text |
133 | set theLongitude to (item 2 of listLL) as text |
134 | |
135 | |
136 | #################################################### |
137 | |
138 | set strFileName to ("" & theLatitude & "-" & theLongitude & ".png") |
139 | ##################################################### |
140 | if objResponse is "AppleMap用" then |
141 | set theChl to ("GEO:" & theLatitude & "," & theLongitude & "") as text |
142 | log theChl |
143 | else if objResponse is "GoogleMap用" then |
144 | |
145 | ###GoogleMap用の小数点以下の桁揃え |
146 | |
147 | (* *) |
148 | set AppleScript's text item delimiters to "." |
149 | set listLatitude to every text item of theLatitude as list |
150 | set AppleScript's text item delimiters to "" |
151 | set strLatitudeInt to text item 1 of listLatitude as text |
152 | set strLatitudeDecimal to text item 2 of listLatitude as text |
153 | set strLatitudeDecimal to (text 1 through 7 of (strLatitudeDecimal & "000000000")) as text |
154 | set theLatitude to ("" & strLatitudeInt & "." & strLatitudeDecimal & "") |
155 | |
156 | set AppleScript's text item delimiters to "." |
157 | set listLongitude to every text item of theLongitude as list |
158 | set AppleScript's text item delimiters to "" |
159 | set strLongitudeInt to text item 1 of listLongitude as text |
160 | set strLongitudeDecimal to text item 2 of listLongitude as text |
161 | set strLongitudeDecimal to (text 1 through 7 of (strLongitudeDecimal & "000000000")) as text |
162 | set theLongitude to ("" & strLongitudeInt & "." & strLongitudeDecimal & "") |
163 | |
164 | set theGooglemapParts to ("@" & theLatitude & "," & theLongitude & ",16z") |
165 | |
166 | set theChl to ("https://www.google.com/maps/" & theGooglemapParts & "") as text |
167 | else |
168 | set theChl to ("http://maps.apple.com/?q=" & theLatitude & "," & theLongitude & "") as text |
169 | end if |
170 | ####################### |
171 | |
172 | |
173 | ###フォルダのパス |
174 | ###ピクチャーフォルダのパス |
175 | tell application "Finder" |
176 | set aliasDirPath to (path to pictures folder from user domain) as alias |
177 | set strDirPath to POSIX path of aliasDirPath as text |
178 | end tell |
179 | ####フォルダ名 |
180 | set strFolderName to "QRcode" as text |
181 | set strDirPath to ("" & strDirPath & strFolderName & "") as text |
182 | ###NSStringテキスト |
183 | set ocidDirPath to objNSString's stringWithString:strDirPath |
184 | ###フォルダを作る |
185 | ###途中のフォルダも作る-->true |
186 | set boolMakeNewFolder to (objFileManager's createDirectoryAtPath:ocidDirPath withIntermediateDirectories:true attributes:(missing value) |error| :(missing value)) |
187 | |
188 | ####ファイルパス |
189 | set strSaveFilePath to ("" & strDirPath & "/" & strFileName & "") as text |
190 | |
191 | |
192 | ################################################################ |
193 | set strInputText to theChl as text |
194 | ####テキストをNSStringに |
195 | set ocidInputString to objNSString's stringWithString:strInputText |
196 | ####テキストをUTF8に |
197 | set ocidUtf8InputString to ocidInputString's dataUsingEncoding:(objMe's NSUTF8StringEncoding) |
198 | ####CIQRCodeGenerator初期化 |
199 | set ocidQRcodeImage to objMe's CIFilter's filterWithName:"CIQRCodeGenerator" |
200 | ocidQRcodeImage's setDefaults() |
201 | ###テキスト設定 |
202 | ocidQRcodeImage's setValue:ocidUtf8InputString forKey:"inputMessage" |
203 | ###読み取り誤差値設定L, M, Q, H |
204 | ocidQRcodeImage's setValue:"Q" forKey:"inputCorrectionLevel" |
205 | ###QRコード本体のイメージ |
206 | set ocidCIImage to ocidQRcodeImage's outputImage() |
207 | -->ここで生成されるのはQRのセルが1x1pxの最小サイズ |
208 | ###QRコードの縦横取得 |
209 | set ocidCIImageDimension to ocidCIImage's extent() |
210 | set ocidCIImageWidth to (item 1 of item 2 of ocidCIImageDimension) as integer |
211 | set ocidCIImageHight to (item 2 of item 2 of ocidCIImageDimension) as integer |
212 | ###最終的に出力したいpxサイズ |
213 | set numScaleMax to 720 |
214 | ###整数で拡大しないとアレなので↑の値のニアなサイズになります |
215 | set numWidth to ((numScaleMax / ocidCIImageWidth) div 1) as integer |
216 | set numHight to ((numScaleMax / ocidCIImageHight) div 1) as integer |
217 | ###↑サイズの拡大縮小する場合はここで値を調整すれば良い |
218 | ####変換スケール作成-->拡大 |
219 | set recordScalse to objMe's CGAffineTransform's CGAffineTransformMakeScale(numWidth, numHight) |
220 | ##変換スケールを適応(元のサイズに元のサイズのスケール適応しても意味ないけど |
221 | set ocidCIImageScaled to ocidCIImage's imageByApplyingTransform:recordScalse |
222 | #######元のセルが1x1pxの最小サイズで出したいときはここで処理 |
223 | ##set ocidCIImageScaled to ocidCIImage |
224 | ###イメージデータを展開 |
225 | set ocidNSCIImageRep to objMe's NSCIImageRep's imageRepWithCIImage:ocidCIImageScaled |
226 | ###出力用のイメージの初期化 |
227 | set ocidNSImageScaled to objMe's NSImage's alloc()'s initWithSize:(ocidNSCIImageRep's |size|()) |
228 | ###イメージデータを合成 |
229 | ocidNSImageScaled's addRepresentation:ocidNSCIImageRep |
230 | ###出来上がったデータはOS_dispatch_data |
231 | set ocidOsDispatchData to ocidNSImageScaled's TIFFRepresentation() |
232 | ####NSBitmapImageRepに |
233 | set ocidNSBitmapImageRep to objMe's NSBitmapImageRep's imageRepWithData:ocidOsDispatchData |
234 | ################################################################# |
235 | ###quiet zone用に画像をパディングする |
236 | set numPadWidth to ((ocidCIImageWidth * numWidth) + (numWidth * 6)) as integer |
237 | set numPadHight to ((ocidCIImageHight * numHight) + (numHight * 6)) as integer |
238 | ###左右に3セル分づつ余白 quiet zoneを足す |
239 | ####まずは元のQRコードのサイズに6セルサイズ分足したサイズの画像を作って |
240 | set ocidNSBitmapImagePadRep to (objMe's NSBitmapImageRep's alloc()'s initWithBitmapDataPlanes:(missing value) pixelsWide:numPadWidth pixelsHigh:numPadHight bitsPerSample:8 samplesPerPixel:4 hasAlpha:true isPlanar:false colorSpaceName:(objMe's NSCalibratedRGBColorSpace) bitmapFormat:(objMe's NSAlphaFirstBitmapFormat) bytesPerRow:0 bitsPerPixel:32) |
241 | ###初期化 |
242 | objMe's NSGraphicsContext's saveGraphicsState() |
243 | ###ビットマップイメージ |
244 | (objMe's NSGraphicsContext's setCurrentContext:(objMe's NSGraphicsContext's graphicsContextWithBitmapImageRep:ocidNSBitmapImagePadRep)) |
245 | ###塗り色を『白』に指定して |
246 | objMe's NSColor's whiteColor()'s |set|() |
247 | ##画像にする |
248 | objMe's NSRectFill({origin:{x:0, y:0}, |size|:{width:numPadWidth, height:numPadHight}}) |
249 | ###出来上がった画像にQRバーコードを左右3セル分ずらした位置にCompositeSourceOverする |
250 | ocidNSBitmapImageRep's drawInRect:{origin:{x:(numWidth * 3), y:(numHight * 3)}, |size|:{width:numPadWidth, Hight:numPadHight}} fromRect:{origin:{x:0, y:0}, |size|:{width:numPadWidth, height:numPadHight}} operation:(objMe's NSCompositeSourceOver) fraction:1.0 respectFlipped:true hints:(missing value) |
251 | ####画像作成終了 |
252 | objMe's NSGraphicsContext's restoreGraphicsState() |
253 | |
254 | ################################################################# |
255 | |
256 | ####JPEG用の圧縮プロパティ |
257 | ##set ocidNSSingleEntryDictionary to objMe's NSDictionary's dictionaryWithObject:1 forKey:(objMe's NSImageCompressionFactor) |
258 | ####PNG用の圧縮プロパティ |
259 | set ocidNSSingleEntryDictionary to objMe's NSDictionary's dictionaryWithObject:true forKey:(objMe's NSImageInterlaced) |
260 | |
261 | #####出力イメージへ変換 |
262 | set ocidNSInlineData to (ocidNSBitmapImagePadRep's representationUsingType:(objMe's NSBitmapImageFileTypePNG) |properties|:ocidNSSingleEntryDictionary) |
263 | |
264 | ######インラインデータをファイルに書き出し |
265 | set boolMakeQrCode to (ocidNSInlineData's writeToFile:strSaveFilePath atomically:true) |
266 | |
267 | set aliasDirPath to POSIX file strDirPath as alias |
268 | ###保存場所を開いて |
269 | tell application "Finder" |
270 | select aliasDirPath |
271 | end tell |
272 | ####プレビューに表示 |
273 | tell application "Preview" |
274 | launch |
275 | activate |
276 | open aliasDirPath |
277 | end tell |
278 | |
279 | |
280 | set theURL to "" |
281 | set the clipboard to theURL |
282 | set ocidNSInlineData to "" |
283 | set ocidNSBitmapImagePadRep to "" |
284 | return true |
285 | |
286 | |
287 | to doReplace(theText, orgStr, newStr) |
288 | set oldDelim to AppleScript's text item delimiters |
289 | set AppleScript's text item delimiters to orgStr |
290 | set tmpList to every text item of theText |
291 | set AppleScript's text item delimiters to newStr |
292 | set tmpStr to tmpList as text |
293 | set AppleScript's text item delimiters to oldDelim |
294 | return tmpStr |
295 | end doReplace |
AppleScriptで生成しました |
| 固定リンク
AppleのURLに誤りがあったので修正
https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html
| 固定リンク
QRバーコードを作ります
セルサイズ『黒い塗りの1単位』が1pxのバーコードを作成します
--->この1pxバーコードを整数倍する事で『アンチエイリアス』の無い規格通りのバーコードができます。
PhotoShop等で拡大する場合は『ニアレストネイバー』で拡大すれば、アンチエイリアス立ちません。
最近の高画質環境では小さな事になりましたが
やっぱり、プロなんだし。ねっ
と、偉そうに…いったものの
最初から1pxなんだよね…出来上がりが。
| 固定リンク
Accessibility Acrobat Acrobat 2020 Acrobat AddOn Acrobat Annotation Acrobat ARMDC Acrobat AV2 Acrobat BookMark Acrobat Classic Acrobat DC Acrobat Dialog Acrobat Distiller Acrobat Form Acrobat JS Acrobat Manifest Acrobat Menu Acrobat Open Acrobat Plugin Acrobat Preferences Acrobat Preflight Acrobat python Acrobat Reader Acrobat SCA Acrobat SCA Updater Acrobat Sequ Acrobat Sign Acrobat Stamps Acrobat Watermark Acrobat Windows Acrobat Windows Reader Admin Admin Account Admin Apachectl Admin configCode Admin Device Management Admin LaunchServices Admin Locationd Admin loginitem Admin Maintenance Admin Mobileconfig Admin Permission Admin Pkg Admin Power Management Admin Printer Admin SetUp Admin SMB Admin Support Admin System Information Admin Tools Admin Users Admin Volumes Adobe Adobe FDKO Adobe RemoteUpdateManager AppKit Apple AppleScript AppleScript do shell script AppleScript List AppleScript ObjC AppleScript Osax AppleScript PDF AppleScript Pictures AppleScript record AppleScript Script Editor AppleScript Script Menu AppleScript Shortcuts AppleScript Shortcuts Events AppleScript System Events AppleScript System Events Plist AppleScript Video Applications AppStore Archive Attributes Automator BackUp Barcode Barcode QR Barcode QR Decode Bash Basic Basic Path Bluetooth BOX Browser Calendar CD/DVD Choose Chrome CIImage CityCode CloudStorage Color com.apple.LaunchServices.OpenWith Console Contacts CotEditor CURL current application Date&Time delimiters Desktop Device Diff Disk Dock DropBox Droplet eMail Encode % Encode Decode Encode UTF8 Error EXIFData ffmpeg File Finder Firefox Folder FolderAction Fonts GIF github Guide HTML HTML Entity Icon Illustrator Image Events Image2PDF ImageOptim iPhone iWork Javascript Jedit Json Label Leading Zero List locationd LRC lsappinfo LSSharedFileList m3u8 Mail MakePDF Map Math Media Media AVAsset Media AVconvert Media AVFoundation Media AVURLAsset Media Movie Media Music Memo Messages Microsoft Microsoft Edge Microsoft Excel Mouse Music NetWork Notes NSArray NSArray Sort NSBezierPath NSBitmapImageRep NSBundle NSCFBoolean NSCharacterSet NSColor NSColorList NSData NSDecimalNumber NSDictionary NSError NSEvent NSFileAttributes NSFileManager NSFileManager enumeratorAtURL NSFont NSFontManager NSGraphicsContext NSImage NSIndex NSKeyedArchiver NSKeyedUnarchiver NSLocale NSMutableArray NSMutableDictionary NSMutableString NSNotFound NSNumber NSOpenPanel NSPasteboard NSpoint NSPredicate NSPrintOperation NSRange NSRect NSRegularExpression NSRunningApplication NSScreen NSSize NSString NSString stringByApplyingTransform NSStringCompareOptions NSTask NSTimeZone NSURL NSURL File NSURLBookmark NSURLComponents NSURLResourceKey NSURLSession NSUserDefaults NSUUID NSView NSWorkspace Numbers OAuth OneDrive PDF PDFAnnotation PDFAnnotationWidget PDFContext PDFDisplayBox PDFDocumentPermissions PDFImageRep PDFKit PDFnUP PDFOutline perl Photoshop PlistBuddy pluginkit postalcode PostScript prefPane Preview Python QuickLook QuickTime ReadMe Regular Expression Reminders ReName Repeat RTF Safari SaveFile ScreenCapture ScreenSaver SF Symbols character id SF Symbols Entity sips Skype Slack Sound Spotlight sqlite SRT StandardAdditions Swift System Settings TCC TemporaryItems Terminal Text Text CSV Text MD Text TSV TextEdit Tools Translate Trash Twitter Typography UI Unit Conversion UTType valueForKeyPath Video VisionKit Visual Studio Code VMware Fusion Wacom webarchive webp Wifi Windows XML XML EPUB XML OPML XML Plist XML RSS XML savedSearch XML SVG XML TTML XML webloc XML XMP YouTube zoom