顯示具有 Soft軟體相關 標籤的文章。 顯示所有文章
顯示具有 Soft軟體相關 標籤的文章。 顯示所有文章

2026年11月24日 星期二

AI神器(AGY CLI)採開放源碼套件,免費生成GIF動畫圖檔

一張可愛的靜態角色圖變成生動的「揮手打招呼 GIF」,直覺往往是丟給生成式 AI(如 Stable Video Diffusion)去算。但實戰上你一定遇過兩大痛點:第一是沒有高階獨立顯卡根本跑不動,第二是 AI 每一幀重繪容易讓角色五官走樣、頭髮亂飄!

其實,只要改用經典的「2D 紙娃娃拆解、背景修補(Inpainting)與關節驅動傳輸線」,純靠 CPU 就能在 0.5 秒內精準驅動手腕揮動,且角色臉部與背景 100% 零變形!

👉 PYTHON核心元件「OpenCV + NumPy + Pillow」全自動動圖管線的底層架構、關鍵程式碼對位。

一、 全景架構圖:2D 紙娃娃拆解與關節驅動傳輸線

這套系統的核心精神是「把會動的手掌剪成透明零件,把被遮住的背景頭髮無痕補齊,最後用三角函數節拍器帶動關節旋轉」。整體信號流如下:

[原始角色圖 chibi_wave_source.jpg]
   ├── 路徑 A(前景零件萃取):ROI 區域鎖定 ──> 膚色閾值篩選 ──> 形態學閉合/膨脹 ──> [透明背景手部零件 hand_rgba]
   └── 路徑 B(背景無痕補洞):手部遮罩擴大 ──> Telea 影像修補 (Inpainting) ────────> [無手部遮擋的完整背景 bg_inpainted]
                                                                                              │
[正弦波節拍器 math.sin] ──> 算出揮手角度 (wave_deg) ──> 繞手腕軸心旋轉手部零件 ──────────────┴──> [圖層 alpha 混合合成]
                                                                                                         │
[呼吸律動產生器] ──> 網格座標重映射 (cv2.remap 邊緣鎖死) ──> [疊加閃亮星星特效] ──> [中位切分 256 色量化] ──> [chibi_wave.gif]

二、 四大核心工程直覺拆解

1. 為什麼要先「背景補洞(Inpainting)」?(解決穿幫難題)

如果直接把原圖的手剪下來旋轉,手揮開之後,原本被手掌遮住的「棕色頭髮」會變成一個白色大破洞!因此程式先用 cv2.inpaint(Telea 演算法)像修圖軟體的「內容感知填補」一樣,把被手遮住的頭髮紋理自動推演補齊,確保手怎麼揮都不會穿幫。

2. 形態學操作(Morphology:閉運算與膨脹)的物理意義

單靠膚色範圍(r > 205...)抓出來的手掌內部會有反光小孔洞,且不包含「深棕色的手部輪廓線」。程式先用 MORPH_CLOSE(閉運算)填平掌心內部孔洞,再用 dilate(膨脹)往外擴張一圈,精準把深色外框線一起包進手部圖層裡。

3. 邊緣鎖死的呼吸律動(cv2.remap + interior 衰減遮罩)

若整張圖直接上下移動,GIF 四周白邊會出現黑線或撕裂。程式設計了一個「越靠近四個邊界、位移量衰減為 0」的平滑阻尼遮罩(interior),讓角色身體中心跟著呼吸微微起伏搖擺,但最外圍 7 像素的邊框死死釘在原地不動。

4. 雙倍頻正弦波節拍器(Double-Wave Oscillator)

一般單週期正弦波一個循環只揮一次手;程式在 wave_deg 中乘上 2.0(2.0 * math.pi * 2.0 * t),讓角色在一次呼吸起伏(t 從 0 到 1)的期間,手腕輕快地來回揮動兩次,呈現活潑的打招呼節奏。

三、 關鍵代碼與工程物理本質對位表

階段步驟 核心程式碼 工程與物理本質 一句話白話直覺
1. 座標比例正規化 sx, sy = w / 296.0, h / 297.0 解析度無關的相對座標映射(Resolution Independence) 不管輸入圖片被放大或縮小,自動按比例換算手掌與手腕的精準座標位置。
2. 膚色與連通域過濾 connectedComponentsWithStats 連通分量標記與面積閾值雜訊濾波 抓出指定區域內的膚色色塊,並把面積太小的零星雜點踢掉,只留下真正的手掌。
3. 邊緣羽化去鋸齒 cv2.GaussianBlur(hand_mask, (3, 3), 0.7) Alpha 透明通道低通濾波抗鋸齒(Anti-Aliasing) 把手部剪貼邊緣微微模糊柔化,讓手掌疊回背景時邊緣自然融合、沒有狗牙鋸齒。
4. 關節仿射旋轉 cv2.getRotationMatrix2D(wrist_pivot, ...)
cv2.warpAffine(...)
2D 剛體繞固定樞紐點之仿射變換(Affine Transformation) 用一根圖釘釘住「手腕軸心」,只讓手掌零件左右擺動,袖口位置完全不動。
5. 色彩量化與抖動 composed.quantize(colors=256, method=MEDIANCUT, dither=FLOYDSTEINBERG) 色彩空間體積中位切分聚類與誤差擴散演算法 把數百萬種全彩顏色濃縮成 256 色,並用細微點陣擴散消除色階斷層。

四、 逐行解構與「順序反轉因果」反事實推導

  • 袖口切割線(wrist_cut_y = int(232 * sy); hand_mask[wrist_cut_y:, :] = 0):在手腕袖口交界處一刀切斷遮罩,確保粉紅色連帽衫袖子留在靜態背景圖層,不會跟著手掌一起歪斜旋轉。
  • 標準 Alpha 混色(rot_hand[:, :, :3] * alpha_f + bg_inpainted * (1.0 - alpha_f)):Porter-Duff 混色公式。透明通道為 1 的地方顯示旋轉後的手,為 0 的地方顯示補好頭髮的背景,介於中間的羽化邊緣則做線性平滑過渡。

⚠️ 順序反轉災難推演(Counterfactual Inversion):

1. 若省略 inpaint_mask = cv2.dilate(hand_mask, ...),直接用未膨脹遮罩修補:手部邊緣的半透明深色外框會殘留在原圖背景上,導致手揮動時,背景印著一圈「幽靈手掌殘影」。

2. 若先執行全身呼吸晃動,再把旋轉後的手貼上去:身體與手腕已經跟著呼吸位移,手部圖層卻還釘在舊的 wrist_pivot 座標上,會導致手掌與袖口當場脫節分離!因此必須「先合體、再呼吸」。

五、 電腦視覺注意事項與優化調校

  1. 色彩通道順序陷阱(OpenCV BGR vs PIL/NumPy RGB):Image.open().convert("RGB") 讀入的是 RGB,但 cv2.inpaint() 內部針對 BGR 優化,因此必須先轉 RGB2BGR 再轉回 BGR2RGB。漏掉轉換會讓角色膚色變成阿凡達藍色!
  2. 幾何變換插值法選擇(Interpolation):cv2.INTER_CUBIC(雙三次插值)參考周圍 4×4 個像素,比最近鄰(INTER_NEAREST)與雙線性(INTER_LINEAR)更能保留二次元動漫線條的銳利與平滑度。
  3. 形態學「閉運算(Closing)」vs「開運算(Opening)」:先膨脹後侵蝕 = 閉運算(MORPH_CLOSE),專治物體內部的小黑洞與斷裂;先侵蝕後膨脹 = 開運算(MORPH_OPEN),專治背景上的孤立小白點雜訊。
  4. 優化調校
  •  手部前景獨立去背(RGBA Sprite):僅擷取手掌、五指與外框黑線成為獨立透明前景圖層。
  • 手後背景髮絲修補(cv2.INPAINT_TELEA):將手掌原本遮擋處的棕色長髮自動補全為靜止背景層。
  • 獨立分層旋轉合成:每一幀僅旋轉手部前景圖層(以手腕為軸心±12°),再疊加回靜止的髮絲背景上,因此揮手時手背後的頭髮完全不會跟著拉扯或晃動,右耳亦完全不受影響。

六、 張量陣列維度演進

  • base_np:shape=(H, W, 3),dtype=uint8(3 通道 RGB 原始影像)。
  • hand_mask:shape=(H, W),dtype=uint8(單通道二值化遮罩,僅含 0 與 255)。
  • hand_rgba:shape=(H, W, 4),dtype=uint8(透過 np.dstack 堆疊為 4 通道 RGBA 精靈圖)。
  • alpha_f:shape=(H, W, 1),dtype=float32(切片 [:, :, 3:4] 保留維度並正規化至 [0.0, 1.0],觸發廣播機制)。
  • quantized:PIL.Image(模式 P,調色盤索引模式,每像素僅佔 1 Byte)。

💡 總結

  1. 生成式 AI(擴散管線 (Diffusers + FFmpeg)) 吃顯存且容易畫崩五官;本次作法採傳統視覺紙娃娃管線 (OpenCV + NumPy + PIL)拆解則是秒殺級運算且 100% 零變形。
  2. 拆圖兩手抓:前景抓膚色加閉運算剪出「透明手掌」,背景用 Telea 修補填平「頭髮破洞」。
  3. 先合體再呼吸:手掌先繞手腕旋轉並貼回身體,最後才用邊界鎖死的 remap 做全身呼吸起伏,保證手腕不斷裂。
  4. 內建壓縮術:無需外部工具,直接用 Pillow 的中位切分法搭配誤差擴散抖動輸出輕量無斷層 GIF。

"""
Generate an animated waving GIF from the chibi character image.
Uses true two-layer foreground/background separation:
  1. Segments the waving hand (palm + fingers + dark outline) into an RGBA sprite.
  2. Inpaints the static brown hair behind the hand (cv2.INPAINT_TELEA) so the hair
     NEVER wobbles or stretches with the waving hand.
  3. Rotates ONLY the foreground hand layer around the wrist pivot and alpha-composites
     it over the background, plus subtle breathing bob and twinkling sparkles.
"""

import math
import os
import shutil
import cv2
import numpy as np
from PIL import Image, ImageDraw


BASE_DIR = os.path.dirname(os.path.abspath(__file__))
DEFAULT_UPLOADED = (
    r"C:\Users\username\.gemini\antigravity-cli\brain"
    r"\ff49392a-1ed7-4e41-af72-a8663610fe5d\.user_uploaded"
    r"\uploaded_media_1795435385706.jpg"
)
SOURCE_IMAGE = os.path.join(BASE_DIR, "chibi_wave_source.jpg")
OUTPUT_GIF = os.path.join(BASE_DIR, "chibi_wave.gif")


def ensure_source_image() -> str:
    if not os.path.exists(SOURCE_IMAGE):
        if os.path.exists(DEFAULT_UPLOADED):
            shutil.copy2(DEFAULT_UPLOADED, SOURCE_IMAGE)
        else:
            raise FileNotFoundError(f"Source image not found: {SOURCE_IMAGE}")
    return SOURCE_IMAGE


def separate_hand_and_background(img_rgb: np.ndarray):
    """
    Separate the waving hand into a crisp RGBA sprite and inpaint the hair behind it.
    Returns (bg_inpainted_rgb, hand_rgba, wrist_pivot_xy).
    """
    h, w = img_rgb.shape[:2]
    sx, sy = w / 296.0, h / 297.0

    # 1. Restrict search strictly to the hand region (well below the right ear y <= 158)
    roi = np.zeros((h, w), dtype=np.uint8)
    roi[int(172 * sy) : int(236 * sy), int(24 * sx) : int(92 * sx)] = 255

    # 2. Segment warm peach skin pixels inside ROI (excludes white bg, brown hair, pink hoodie)
    r = img_rgb[:, :, 0].astype(np.int16)
    g = img_rgb[:, :, 1].astype(np.int16)
    b = img_rgb[:, :, 2].astype(np.int16)
    skin = (
        (r > 205)
        & (g > 165)
        & (b > 130)
        & ((r - b) > 18)
        & ((r - g) < 55)
    ).astype(np.uint8) * 255
    skin = cv2.bitwise_and(skin, roi)

    # Keep only meaningful skin components (hand palm + fingers)
    num_labels, labels, stats, _ = cv2.connectedComponentsWithStats(skin, connectivity=8)
    hand_skin = np.zeros((h, w), dtype=np.uint8)
    for lbl in range(1, num_labels):
        if stats[lbl, cv2.CC_STAT_AREA] >= int(35 * sx * sy):
            hand_skin[labels == lbl] = 255

    # Fill tiny interior holes and dilate tightly to capture the dark brown finger outline
    hand_skin = cv2.morphologyEx(
        hand_skin,
        cv2.MORPH_CLOSE,
        cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (5, 5)),
    )
    hand_mask = cv2.dilate(
        hand_skin,
        cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (5, 5)),
        iterations=1,
    )

    # Trim cleanly at the wrist cuff line so the pink sleeve stays anchored
    wrist_cut_y = int(232 * sy)
    hand_mask[wrist_cut_y:, :] = 0

    # 3. Inpaint the background hair behind the hand
    inpaint_mask = cv2.dilate(
        hand_mask,
        cv2.getStructuringElement(cv2.MORPH_ELLIPSE, (5, 5)),
        iterations=1,
    )
    bg_bgr = cv2.inpaint(
        cv2.cvtColor(img_rgb, cv2.COLOR_RGB2BGR),
        inpaint_mask,
        inpaintRadius=7,
        flags=cv2.INPAINT_TELEA,
    )
    bg_inpainted = cv2.cvtColor(bg_bgr, cv2.COLOR_BGR2RGB)

    # 4. Anti-aliased alpha channel for the hand sprite
    alpha = cv2.GaussianBlur(hand_mask.astype(np.float32), (3, 3), 0.7)
    alpha = np.clip(alpha, 0.0, 255.0).astype(np.uint8)
    hand_rgba = np.dstack([img_rgb, alpha])

    wrist_pivot = (62.0 * sx, 231.0 * sy)
    return bg_inpainted, hand_rgba, wrist_pivot


def apply_gentle_bob(img_rgb: np.ndarray, bob_y: float, sway_deg: float) -> np.ndarray:
    """Apply subtle whole-character breathing bob while keeping outer border static."""
    h, w = img_rgb.shape[:2]
    yy, xx = np.mgrid[0:h, 0:w].astype(np.float32)

    cx_g, cy_g = w * 0.50, h * 0.94
    rad_g = math.radians(-sway_deg)
    cos_g, sin_g = math.cos(rad_g), math.sin(rad_g)
    dx_g = xx - cx_g
    dy_g = (yy - bob_y) - cy_g
    map_x = cx_g + dx_g * cos_g - dy_g * sin_g
    map_y = cy_g + dx_g * sin_g + dy_g * cos_g

    border = 7.0
    mask_x = np.clip(np.minimum(xx - border, (w - 1 - border) - xx) / 10.0, 0.0, 1.0)
    mask_y = np.clip(np.minimum(yy - border, (h - 1 - border) - yy) / 10.0, 0.0, 1.0)
    interior = mask_x * mask_y

    map_x = xx + (map_x - xx) * interior
    map_y = yy + (map_y - yy) * interior

    return cv2.remap(
        img_rgb,
        map_x.astype(np.float32),
        map_y.astype(np.float32),
        interpolation=cv2.INTER_CUBIC,
        borderMode=cv2.BORDER_REPLICATE,
    )


def draw_sparkle(draw: ImageDraw.ImageDraw, cx: float, cy: float, size: float, color: tuple):
    """Draw a cute 4-point star sparkle."""
    if size <= 1.0:
        return
    r_outer = size
    r_inner = size * 0.28
    pts = []
    for i in range(8):
        angle = i * math.pi / 4.0
        r = r_outer if i % 2 == 0 else r_inner
        pts.append((cx + r * math.cos(angle), cy + r * math.sin(angle)))
    draw.polygon(pts, fill=color)


def generate_gif(num_frames: int = 24, duration_ms: int = 65) -> str:
    src_path = ensure_source_image()
    base_pil = Image.open(src_path).convert("RGB")
    base_np = np.array(base_pil)
    w, h = base_pil.size

    bg_inpainted, hand_rgba, wrist_pivot = separate_hand_and_background(base_np)

    frames = []
    sparkles = [
        (w * 0.11, h * 0.36, 0.0, (255, 165, 185, 220)),
        (w * 0.13, h * 0.55, 0.33, (255, 205, 110, 220)),
        (w * 0.87, h * 0.16, 0.55, (255, 190, 120, 220)),
        (w * 0.89, h * 0.34, 0.78, (255, 155, 175, 200)),
    ]

    for i in range(num_frames):
        t = i / num_frames
        # Double wave per loop for lively greeting feel
        wave_deg = 12.0 * math.sin(2.0 * math.pi * 2.0 * t)
        # Subtle breathing bob & tiny head sway (applied cleanly to whole character)
        bob_y = -1.8 * math.sin(2.0 * math.pi * t)
        sway_deg = 1.0 * math.sin(2.0 * math.pi * t)

        # Rotate ONLY the isolated hand sprite around the wrist pivot
        rot_mat = cv2.getRotationMatrix2D(wrist_pivot, wave_deg, 1.0)
        rot_hand = cv2.warpAffine(
            hand_rgba,
            rot_mat,
            (w, h),
            flags=cv2.INTER_CUBIC,
            borderMode=cv2.BORDER_CONSTANT,
            borderValue=(0, 0, 0, 0),
        )

        # Composite rotated hand onto static inpainted background (hair never wobbles!)
        alpha_f = (rot_hand[:, :, 3:4].astype(np.float32)) / 255.0
        comp_rgb = (
            rot_hand[:, :, :3].astype(np.float32) * alpha_f
            + bg_inpainted.astype(np.float32) * (1.0 - alpha_f)
        ).clip(0, 255).astype(np.uint8)

        # Apply subtle global breathing bob
        frame_rgb = apply_gentle_bob(comp_rgb, bob_y, sway_deg)
        frame_rgba = Image.fromarray(frame_rgb).convert("RGBA")

        # Overlay twinkling sparkles
        overlay = Image.new("RGBA", (w, h), (0, 0, 0, 0))
        draw = ImageDraw.Draw(overlay)
        for sx, sy, phase, rgba in sparkles:
            pulse = 0.5 + 0.5 * math.sin(2.0 * math.pi * (t + phase))
            star_size = 2.0 + 6.5 * (pulse ** 1.6)
            a = int(rgba[3] * (0.25 + 0.75 * pulse))
            draw_sparkle(draw, sx, sy + bob_y * 0.6, star_size, (rgba[0], rgba[1], rgba[2], a))

        composed = Image.alpha_composite(frame_rgba, overlay).convert("RGB")
        quantized = composed.quantize(
            colors=256,
            method=Image.Quantize.MEDIANCUT,
            dither=Image.Dither.FLOYDSTEINBERG,
        )
        frames.append(quantized)

    frames[0].save(
        OUTPUT_GIF,
        save_all=True,
        append_images=frames[1:],
        duration=duration_ms,
        loop=0,
        optimize=True,
    )
    return OUTPUT_GIF


if __name__ == "__main__":
    out = generate_gif()
    size_kb = os.path.getsize(out) / 1024.0
    print(f"GIF_GENERATED_OK: {out} ({size_kb:.1f} KB)")

2026年4月8日 星期三

Skill-Creator 建立新技能(Gemini CLI)

情境: 

因為常常重覆性使用除錯 (如:下方除錯資源2、混搭除錯資源1,將2除錯資源搓進精靈式技能生成器),但每次都要打一長串PROMPT提示詞,所以可以藉由內建創建技能功能進行活用。 

Step1: Activate_skill Skill-Creator 

建立新技能或更新現有技能。請問您想要建立什麼樣的技能

Step2: 可否以類似精靈(Wizard)類似功能,STEP BY STEP 協助使用者生成技能SKILL  

Gemini神器,就會像阿拉丁神燈🧞‍♂️呼喚出來,依主人(您)的需求,達成所要的願望😁   

第 1 階段:定義技能目標與情境 (Understanding)

  在動手寫程式碼之前,我們需要明確這個技能的「靈魂」。請回答以下幾個問題:

   1. 技能名稱:您想為這個技能取什麼名字?(例如:python-data-cleaner 或 api-tester)
   2. 核心功能:這個技能主要解決什麼問題?請描述 2-3 個具體的使用情境。
   3. 觸發條件:使用者說了什麼話時,應該啟動這個技能?(例如:「幫我清理這份 CSV」)

Step 3: 執行SKILL技能「佈署 (Deployment)」程序(正式佈署到 .gemini\skills(即 Runtime 環境))

1. 執行速度與響應延遲 (Performance & Latency)

當技能留在 Arsenal (源碼庫) 時,Gemini 每次執行都需要重新解析、掃描依賴關係,甚至可能需要載入額外的開發環境變數。佈署後: 技能會被「編譯/打包」成優化後的二進位或快取格式存放在 .gemini\skills。 呼叫 deep-rca-expert 的反應時間會大幅縮短。

2. 環境隔離與版本鎖定 (Environment Isolation)

佈署後: 該技能會擁有自己獨立的執行快照(Snapshot),可確保除錯專家在執行緊急任務時,不受開發中不穩定程式碼的影響。這就是為什麼它被稱為「唯執行區 (Runtime)」,它是被保護的。

3. 指令集優化與系統權限 (Privilege & Integration)

Gemini CLI 對於 .gemini\skills 目錄下的技能擁有更高階的信任度與系統整合權限。

佈署後: 系統能預先載入特定的診斷參數,並將 deep-rca-expert 註冊為系統級別的「熱鍵」或「自動觸發器」。您不再只是「呼叫」一個指令,而是讓這個專家成為系統背景守護(Daemon)的一部分,能夠自動監測物理診斷數據,而非等您手動下令。

  
💜1. 層級架構:Skill Manager 是核心(主控層)

    Skill Manager:可以想像成操作系統的「核心 (Kernel)」,它管理所有技能的狀態。

    activate_skill:這是 Skill Manager 提供的一個功能介面(Function call / Action)。當你執行這個指令時,是在調用 Manager 的「啟動」權限。

    skill-creator:這是一個外部工具或腳本層(Utility Layer)。它通常位於 Skill Manager 的「上方」或「平行位」,用於定義、編輯並將新技能「餵」給 Manager。

💜2. 運作流程(路徑)

    Discovery (發現):Manager 掃描可用資源,確定技能存在。

    Activation (啟動):透過 activate_skill 將靜態定義轉為記憶體中的活動實例。

    Path Binding (路徑綁定):將啟動後的技能與特定的輸入/輸出路徑(例如特定的硬體接口或 API 端點)進行連結。

💜一般情況下,Skill Manager 會優先選擇 .gemini/skills 目錄。但仍可客製化專案,將所有擴充能力(Skills)「重定向」,如下專案範例:強制將輸出路徑定錨於指定目錄 ipas_core\arsenal。


 運作路徑對照案例
│ 層級               │ 預設路徑 (Default)                │ 專案路徑 (Project Mandate) │
│ 全域 (Global)  │ ~/.gemini/skills                    │ N/A (基於安全隔離禁令)     │
│ 專案 (Project) │ ./.gemini/skills                     │ C:\ipas_core\arsenal         │
    
其他相關技能指令 

💜除了啟動,通常還包含以下維護技能狀態的指令:

    deactivate_skill:釋放資源,將技能移回靜態存儲。

    register_skill:手動向 Manager 註冊一個新路徑,常用於 skill-creator 產出後的導入。

    list_active_skills:查詢當前所有已綁定(Bound)並在運行的技能清單。

    update_skill_binding:在不重啟技能的情況下,動態更改其綁定的路徑或參數。

 💜確認新專家(即Wizard依您的需求生成的SKILL)的存在檢核?
   1. /skills reload
   2. /skills list 

資料來源:Gemini 

💟除錯資源1: GEMINI CLI開發環境,常見三種自動化檢核AGENT(除錯神器)

💟除錯資源2: 善用DEEP THINK神器,協助找尋系統開發瓶頸問題之提示詞PROMPT

💟Skill-Creator 建立新技能(Gemini CLI) 瓶頸Bottlenecks

 

2024年6月30日 星期日

一鍵完成圖檔OCR辦識,免除打字處理

情境:YOUTUBE上有許多優秀的日文老師的提供考題解析或文法解析,不過有時仍想再藉助AI神器分析解題或文法,只是部分YT,並未提供SRT字幕SubRip subtitle file,可以免去打字處理,此時就需透過手動截圖方式(PNG、JPEG),貼到小畫家後,另存成圖檔,再轉交由OCR辨識軟體將日文辨識出來,進行解題,過程有些繁瑣。

解決辦法:
透過PYTHON程式,將下面程式另存成png2txt.jp,編譯成png2txt.EXE執行檔後,直接於截圖後,使用下面之步驟二方式,一鍵完成日文OCR辨識處理。
由系統快取資訊,取得剛才截圖資訊,直接提供給OCR辨識軟體(Tesseract )轉換成純文字,最後將它交給AI神器進行解題即可 (無需另外開啟小畫家,存檔覆寫等處理)


💜操作步驟一(截圖處理): Shift + Win + S 快速鍵,區塊截取圖片轉換為日文TXT純文字,ScreenShot圖檔即可用PYTHON程式直接取用 CACHE記憶體內之截圖資訊
💜步驟二:點選執行,預先編譯好之png2txt.EXE執行檔,即可一鍵完成日文OCR辦識處理。
💜步驟三:複製剛辨識完成之TXT檔,貼至AI神器💯上去詢問日文考題解析或文法解析。


相關資源:
YOUTUBE字幕下載
OCR辨識軟體🔣(圖檔轉文字jpg2txt)Tesseract
🏯AI神器解析日文考題或句子結構

Mac 上的 Shift + Command + 4 組合鍵,類似 Windows 上的 Win + Shift + S,可方便地選擇性截取螢幕的一部分。


# -*- coding: utf-8 -*-
'''
python取圖檔,辨識日文考題
'''
import os
import subprocess
import sys
from PIL import Image, ImageGrab
import pytesseract

def save_clipboard_image(filename='screenshot.png'):
    try:
        # 獲取剪貼簿中的圖像
        image = ImageGrab.grabclipboard()

        if image is None:
            print("剪貼簿中沒有圖像資料")
            return

        # 保存圖像為PNG格式,覆蓋同名文件
        image.save(filename, 'PNG')
        print(f"圖像已保存為 {filename}")

    except Exception as e:
        print(f"無法保存圖像: {e}", file=sys.stderr)

def ocr_image_to_text(image_path):
    # 檢查檔案是否存在
    if not os.path.exists(image_path):
        print(f"Error: File not found - {image_path}")
        return

    # 修改為您的 Tesseract 安裝路徑
    pytesseract.pytesseract.tesseract_cmd = 'd:/Program Files/Tesseract-OCR/tesseract.exe'

    img = Image.open(image_path)
    text = pytesseract.image_to_string(img, lang='jpn')  # 辨識日文考題

    # 輸出檔案名稱根據輸入檔案修改
    output_file = os.path.splitext(image_path)[0] + '.txt'
    with open(output_file, mode='w', encoding='UTF-8') as f:
        f.write(text)

    print(f"OCR結果已保存為 {output_file}")
    subprocess.Popen(['explorer', output_file])  # 使用 list 形式傳遞參數

if __name__ == "__main__":
    image_filename = 'D:\Program Files\Tesseract-OCR\screenshot.png'
   
save_clipboard_image(image_filename)
    ocr_image_to_text(image_filename)

 

 ###################################################

#以下為進階python版本之 一鍵完成圖檔OCR辨識: (直接將prompt日文提示詞,併入掃描ocr辨識結果,結合起來後,直接自動化用檔案總管開啟 d:\testjlpt.txt')

# input_file1內容,如下:

あなたは日本語のプロで、国語の問題を解きの達人です。

{{問題文}}は1~4の中から最も適切なものを一つ選んでください。

(中略)

"""
問題文:

 

# input_file2內容為     """  
#為何要另外加入
input_file2.txt ,是為了將 4選1選項問答PROMPT提問文:  +OCR辨識之TXT結果後,再補上 """ (三重引用符號),讓AI能夠將它視為整段完整之PROMPT提問文  (亦即,前段日文詢問之PROMPT + OCR辨識後之TXT +最後再補上  三重引用符號)

# output_file內容為  d:\testjlpt.txt'   

 

import os
import subprocess
from PIL import Image, ImageGrab
import pytesseract

def save_clipboard_image(filename='screenshot.png'):
    """保存剪貼簿中的圖像。"""
    image = ImageGrab.grabclipboard()
    if image:
        image.save(filename, 'PNG')
        print(f"圖像已保存為 {filename}")
        return filename
    else:
        print("剪貼簿中沒有圖像資料")
        return None


def ocr_image_to_text(image_path, lang='jpn'):
    """使用 Tesseract OCR 對圖像進行文字辨識。"""
    if not os.path.exists(image_path):
        print(f"Error: File not found - {image_path}")
        return None

    pytesseract.pytesseract.tesseract_cmd = r'D:/Program Files/Tesseract-OCR/tesseract.exe'
    return pytesseract.image_to_string(Image.open(image_path), lang=lang)


def append_file_content_in_order(input_file1, input_file2, content_to_append, output_file):
    """將指定內容和兩個檔案的內容按照指定順序追加到檔案末尾。"""
    try:
        with open(output_file, 'w', encoding='utf-8') as f_out, \
                open(input_file1, 'r', encoding='utf-8') as f_in1, \
                open(input_file2, 'r', encoding='utf-8') as f_in2:

            f_out.write(f_in1.read())  # 先
寫入 input_file1 内容 (00)
            f_out.write("\n\n" + content_to_append)  # 再
寫入 OCR 結果
            f_out.write("\n\n" + f_in2.read())  # 最后
寫入 input_file2 内容 (01)

        print(f"已成功將結果寫入 {output_file}")

    except FileNotFoundError as e:
        print(f"Error: 檔案不存在 - {e.filename}")
    except Exception as e:
        print(f"Error: 發生錯誤 - {e}")


if __name__ == "__main__":
    image_filename = r'D:\Program Files\Tesseract-OCR\screenshot.png'
    input_file1 = r'd:\testjlpt00.txt'
    input_file2 = r'd:\testjlpt01.txt'
    output_file = r'd:\testjlpt.txt'

    saved_image_path = save_clipboard_image(image_filename)
    if saved_image_path:
        ocr_text = ocr_image_to_text(saved_image_path)

        if ocr_text:
            append_file_content_in_order(input_file1, input_file2, ocr_text, output_file)

            print(f"OCR結果已保存為 {output_file}")
            subprocess.Popen(['explorer', output_file])
 

2024年4月9日 星期二

APPLE 內建強大捷徑功能(URL Schemes機制),進行 語言與地區 之 語言界面切換

運用APPLE 內建強大捷徑功能(URL Schemes機制),快速進行 作業系統語言界面之切換

只需3個步驟:  (可命名為 ChangeLanguage, 對Siri說 ChangeLanguage捷徑,直接跳出⌈偏好的語言⌋設定畫面)

步驟1: 開啟捷徑 | 加入動作 (下方  搜尋App 和動作  ,鍵入 URL)

步驟2:選擇  打開URL

步驟3: URL處鍵入字串  prefs:root=General&path=INTERNATIONAL/DEVICE_LANGUAGE

(需完全一樣,有區分大小寫)

 

💜另外,SIRI聲音之設定,亦可用相同機制,完成設定,只需將步驟3的字串,改成:

prefs:root=SIRI&path=LANGUAGE_ID

 

💜 可用 ⌈ 從選單中選擇⌋之捷徑,一次僅設定將它們分開各自設定。

 

其它URL Scheme設定:

電池Battery Health: prefs:root=BATTERY_USAGE&path=BATTERY_HEALTH

手機定位服務           prefs:root=Privacy&path=LOCATION 


後記說明:

一、如不知道如何設定上面URL SCHEMES參數設定? 可參考前篇⌈生成AI捷徑專家⌋,將您的需求,更換成下面Prompt提示詞(藍色部分)即可。

"""
default input: manual

Requirements: Chang Language Setting
By default, the volume is muted, so there is no need for the "Speak" setting.
 

URL
打開URL

URL處鍵入字串  prefs:root=General&path=INTERNATIONAL/DEVICE_LANGUAGE
"""

二、經實際試用免費版Gemini Advance(試用2個月),Advance版本其產出來的結果,通常可更加精準的產出😅

2024年4月8日 星期一

運用APPLE內建語音功能 口說聽寫運用範例 (將⌈聽寫文字⌋ 傳至 教育部字典網頁 )

運用前篇 APPLE 內建口說強大功能 ,將中文口說字串,直接傳送給  教育部字典,可快速語音查詢

英文版Shortcuts捷徑 輔助設定工具


使用說明:

💜將本 捷徑 ,命名為 ⌈教育部字典⌋,用Hey Siri ,打開 教育部字典 捷徑,

☺💟Siri叫出此 捷徑後,她會詢問  文字內容是什麼  ,您只要唸出要查的字 即可


語音使用範例1:
PROMPT 提示詞如下:   (請注意:下面聽寫的文字,是選取變數,而不是用KEYIN 文字)

你是 iPhone 捷徑 Shortcuts(高级技巧)的操作使用教學達人。

請參考 APPLE 官方 捷徑操作文件(如:快捷指令使用手册、高級快捷指令、快捷指令大全、Shortcuts Gallery)做為設定參照之參考依據。
或Apple GALLERY資料庫 有現成與 {{使用需求}} 亦可直接提供
或 Google搜索引擎中搜索 shortcuts {{使用需求}}範例

請盡可能以簡潔易懂方式 STEP BY STEP的操作教學。

{{預設輸入}} 如為 人工手動 ,不藉助SIRI 語音输入功能 ,
若 {{預設輸入}} 如為 SIRI語音輸入,輸入想結合 藉由SIRI 語音输入功能,可將欲查詢KEYWORD關鍵字,做為輸入主要來源 


如果為網頁需求,請參考下面內建功能
捷徑功能 網頁 URL相關功能 JavaScript 通过使用 WEBURL 页面和 URL 相关等操作组件设置功能

以利傳送 KEYWORD 关键字,給欲查詢的網站

如果非網頁需求,請參照官方手冊,提供詳列出操作資訊

最後,請於YOUTUBE影音網站,找尋 與{{使用需求}}主要相關連之資訊出來

"""
預設輸入:人工手動

使用需求:聽寫 中文(台灣) 傳送 網站查詢

預設以 人工手動方式輸入,暫無需 使用 Siri 語音輸入


聽寫文字  語言  中文(台灣) 

打開 URL     https://dict.revised.moe.edu.tw/search.jsp?md=1&word=      聽寫的文字

"""


2024年4月5日 星期五

找尋Youtube影片,節錄重點工具

運用先前AI協助軟體分析檢視工具,快速掌握軟體概況( 開放源碼、Platform、優點、安裝方式、使用注意事項等)

Now that you are a software usage criticism, please analyze the content of each topic based on the resource help I have provided and write about it in a blog format.
First of all, please find out if the features are available based on the resource help I provided, and if it is an open source resource, please describe it separately.
Analyze the copyright (e.g., open source, commercial software, etc.), whether it supports cross-platform (list the details), the advantages of the software (list the supported file formats), the installation method and the matters that need to be paid attention to when you use it (do you need to prepare the environment first?). Please list them in a simple table.

Finally, please list relevant resources, such as the official website, and the more popular websites on the Internet for users who go to Google to search for the software in different languages (e.g. English, Japanese, Chinese).

Please convert the results to Traditional Chinese for a complete and detailed description and table presentation.

I provide the following resources:

"""
整理 YouTube 影片重點的工具:

    NoteGPT:NoteGPT  Chrome
    Chat YouTube:
    Otter.ai:
    thaw.ai:
    chatGPT BOX
    summarize.tech

    no-lang.com
    ScreenApp.ai
    Notta AI Summarizer
    Resoomer

"""

影片字幕 擷取軟體:

DownSub  SubRip subtitle file (SRT文字格式)

SubDownloader 

2024年3月3日 星期日

數個m4a音檔,轉換成單一 MP3

 情境:手機之「語音備忘錄」(錄音程式),產出格式為m4a音檔,但想轉換成MP3音檔🎶

 📌需預先備妥轉換程式:  

💚(開放源碼)ffmpeg轉檔工具,支援跨平台系統

💚可先安裝好Chocolatey工具,直接於Windows命令提示模式下,執行安裝ffmpeg指令
choco install ffmpeg

💚安裝 ffmpeg工具後, 執行python m4a_to_mp3.py,可將單一m4a音檔 或多個m4a(需先將自己錄好的m4a音檔,預先改檔名成 file1.m4a 、file2.m4a、 file3.m4a、  ~,以利PYHTON程式做轉換) ,轉換成Mp3音樂檔案格式

💚解決方式:可使用Python程式(如下藍色部分,另存成m4a_to_mp3.py),將數個m4a檔(檔名自file1.m4a 、file2.m4a、系統會自動將所有file*.m4a檔合併起來),最後轉換成單一MP3音檔(Output.mp3)

import os

def convert_m4a_to_mp3(input_files, output_file):
    # 確認輸入來源之檔案,是否存在?
    for file in input_files:
        if not os.path.exists(file):
            print(f"來源檔案 '{file}' 不存在.")
            return False
    
    # 合併清單M4A檔案
    input_list_path = 'input_list.txt'
    with open(input_list_path, 'w') as f:
        for file in input_files:
            f.write(f"file '{file}'\n")
    
    try:
        os.system(f"ffmpeg -f concat -safe 0 -i {input_list_path} -c copy merged.m4a")
    except Exception as e:
        print(f"合併檔案時,發生錯誤: {e}")
        return False
    
    # 轉換為MP3格式
    try:
        os.system("ffmpeg -i merged.m4a -acodec libmp3lame -ab 256k -ar 44100 -y output.mp3")
    except Exception as e:
        print(f"轉換檔案時,發生錯誤: {e}")
        return False
    
    # 删除臨時交換檔案
    os.remove(input_list_path)
    os.remove("merged.m4a")
    
    print("合併 & 轉檔完成.")
    return True

if __name__ == "__main__":
    input_files = []
    output_file = "output.mp3"  # 輸出MP3檔案名稱
    file_index = 1
    while True:
        file_name = f"file{file_index}.m4a"
        if os.path.exists(file_name):
            input_files.append(file_name)
            file_index += 1
        else:
            break

    if len(input_files) == 0:
        print("未找到file1.m4a 聲檔,系統將合併file1.m4a file2.m4a ~ 依序載入到最後,並自動轉出成Output.mp3格式.")
    else:
        if convert_m4a_to_mp3(input_files, output_file):
            print(f"轉換檔案完成,輸出檔案名稱為 '{output_file}'")
 




Chocolatey 好用Windows套件,軟體安裝工具

Chocolatey ,好用Windows軟體指令方式,安裝工具套件


refreshenv 直接在命令提示模式下此指令,

可以無需重新開機,直接重載生效 Environment variables 環境變數。



參考套件:
https://community.chocolatey.org/packages



2024年2月28日 星期三

HEIC 2 JPG 圖檔轉換(1鍵完成數百筆HEIC圖檔轉換)

情境:因iPhone拍攝出來的照片為HEIC格式,但一次有數百張要轉換成JPG圖檔格式,所以可事先安裝好跨平台影像處理軟體 ,並搭配BATCH批次檔程式,即可一鍵完成圖檔轉換工作。

(開放源碼)需先安裝好ImageMagick工具程式。

BATCH批次檔,如下(藍色部分):

@echo off
setlocal enabledelayedexpansion

rem 指定HEIC資料夾路徑(將所有要轉換的HEIC圖檔,複製到此D:\TEMP資料夾)
set "input_folder=D:\temp"

rem 確保轉檔後,輸出資料夾存在 (即D:\temp\output)
if not exist "%input_folder%\output" mkdir "%input_folder%\output"

rem 逐一捉取HEIC所有檔案,將D:\temp資料夾中的每個HEIC檔案,進行抽取
for %%i in ("%input_folder%\*.heic") do (
    rem 產出檔案名稱(以輸入來源為基準,做為檔名)
    set "filename=%%~ni"

    rem 執行CLI命令提示方式,進行圖檔轉換處理

   rem 指令下法一

 
    convert "%%i" -quality 100 -limit memory 32MiB -limit map 64MiB -write "%input_folder%\output\!filename!.jpg"

rem 指令下法二 (如執行下法二時,去除前方 rem註解  ,並請於下法一最前方增加rem)

rem convert "%%i" -resize 1024*768  -quality 85 -limit memory  64MiB -write "%input_folder%\output\!filename!.jpg"
)

echo 圖檔轉換完成。
pause

 

安裝注意事項:

一、目前主流以64位元電腦為主,建議電腦為64 bits。

二、安裝ImageMagick時,建議點選下方選項,備妥電腦轉換環境

Add Application directory to your system path

Install legacy utilities (e.g. convert )

Install development headers for c and c++

三、官方建議,如遇問題

If you have any problems, you likely need vcomp140.dll. To install it, download Visual C++ Redistributable Package.

四、如還是無法執行,可再詢問Gemini ,

告知您執行ImageMagick ,下的指令為何? 錯誤訊息為何? 請告知原因為何?並請協助修改 指令參數 ,請AI協助DEBUG。

 

相關查詢:
ImageMagick(支援跨平台系統)

 iPhoneで撮影した写真をJPEGに変換する方法


2024年2月4日 星期日

藉由AI神器,試作 軟體解讀工具

 情境:想透過AI神器幫忙,確認是否有相關類似功能之軟體,包含軟體版權、功能簡介,及官方網站,進行軟體的解讀。

說明一:因為AI主要以英文為主,故先將想查詢資訊以中文打好,再經由翻譯軟體或請AI神器預先翻成英文去提問,或許可獲得更多的資訊,最後再轉換成繁體中文呈現。建議可將要查的軟體相關關鍵字(或者是過去自己寫的部落格之軟體文章貼進去,就彷彿跳進時空之旅🌌)用"""      """,(三重引用符號)標示起來,軟體解讀PROMPT提示詞如下面藍色部分。

說明二:使用方式,請將下面PROMPT提示詞樣版,複製貼到AI神器去查詢。

Now that you are a software usage criticism, please analyze the content of each topic based on the resource help I have provided and write about it in a blog format.
First of all, please find out if the features are available based on the resource help I provided, and if it is an open source resource, please describe it separately.
Analyze the copyright (e.g., open source, commercial software, etc.), whether it supports cross-platform (list the details), the advantages of the software (list the supported file formats), the installation method and the matters that need to be paid attention to when you use it (do you need to prepare the environment first?). Please list them in a simple table.

Finally, please list relevant resources, such as the official website, and the more popular websites on the Internet for users who go to Google to search for the software in different languages (e.g. English, Japanese, Chinese).

Please convert the results to Traditional Chinese for a complete and detailed description and table presentation.

I provide the following resources:
"""

https://github.com/upscayl/upscayl 像素不足功能,調整圖像大小。

ImageMagick: https://imagemagick.org/ ,可用於各種圖像處理任務,包括命令提示方式 調整圖像大小


"""

 

Imagemagick 1次性,以命令提示方式,將iPhone之 heic圖檔,轉換成JPG圖檔
convert *.heic -quality 90 -resize 50% -write output/*.jpg

 

Image UpScaling 相片解析度調整工具

 情境:有時照片像素不足,較不清晰,可透過開放源碼相關免費軟體資源,幫忙做轉換處理

  軟體名稱 (版權、跨平台支援否)           安裝方式(含使用)、支援檔案類型

Upscayl

(開源、支援跨平台)

https://github.com/upscayl/upscayl/discussions

依作業系統不同,下載安裝檔安裝

(支援PNG, JPEG, BMP, TIFF, WebP)

ImageMagick

(開源、支援跨平台)

https://www.imagemagick.org/discourse-server/

同上 (支援GIF, PNG, JPEG, PDF, SVG 等)

convert input.jpg -resize 640x480 utput.jpg

 

相關查詢:

Upcayl imageupscaling

照片模糊  去噪點 除霧 去噪點

去除浮水印

2023年12月7日 星期四

jpg2txt圖檔轉換為文字檔(PYTHON)

作業環境前置準備:

 安裝必要性元件(辨識核心元件tesseract-ocr 需下載安裝,外加要辦識之語系)

 

安裝相關套件

 pip install pillow

 pip install pytesseract

 

 PYTHON程式,如下:

# -*- coding: utf-8 -*-
'''
python取圖檔,辨識中文
'''
#'開啟檔案總管 (開啟轉換後之檔案使用)'
import os,sys
import subprocess
import glob
from os import path

from PIL import Image
import pytesseract

# 檢查命令列參數是否足夠
if len(sys.argv) < 2:
    print("Usage: python ocr_script.py <image_file>")
    sys.exit(1)  # 結束程式,返回錯誤碼

file_path = sys.argv[1]  # 取得第一個命令列參數作為檔案路徑

#'預設位址如下,但如安裝不同處,需告訴PYHTON 辨識核心元件在哪,如此方能辦識處理
pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files/Tesseract-OCR/tesseract.exe'

img = Image.open(file_path)

#辯識如為繁體中文字之圖檔,參數為'chi_tra' ;🏯日文字之圖檔,參數改為'jpn'
text1 = pytesseract.image_to_string(img, lang='chi_tra')

#出現UnicodeEncodeError: 'cp950' codec can't encode character '\u5f53',需再加入UTF8編碼,
如下open('file.txt', mode = 'w', encoding='UTF-8')

 with open('file.txt', mode = 'w') as f:
    f.write(text1)
    f.close()

#'將剛才圖檔辨識後結果,以檔案總管直接將它開啟查閱
subprocess.Popen('explorer "file.txt"')
    

運用方式1:可將您未提供字幕YOUTUBE網站,不瞭解的日文考題,截圖辦識成純文字後(將PYTHON編譯成EXE,再透過圖檔右鍵傳送到EXE檔(shell:sendto),立即取得日文純文字考題),再貼到 AI神器去解析考題,省去打字時間 。

運用方式2:以目前AI辦識技術已非難事,將截圖片段直接上傳AI,無需透過本程式,亦是另一種可行方式,但缺點是需考量上傳資料是否涉機敏性(如:公司公文、個資等),如有就可使用此離線工具做轉換辨識處理。


相關參考資訊:

Mac系統OCR辨識工具


2022年8月19日 星期五

Json2Csv(JavaScript Object Notation轉換成CSV格式)

 作法1:( react-gh-pages離線套件)
將JSON格式轉換成CSV純文字讀取格式工具
步驟1:下載解壓縮 react-gh-pages
步驟2:開啟json-gh-pages資料夾下之 index.html
步驟3:將JSON格式貼於上方視窗,即可轉換成 CSV純文字格式 (預設20筆,點選Download the entire CSV)



作法2:(搭配Notepad++ 外掛工具)
經由Notepad++外掛方式(Plug-in)


作法3:(Python程式)

#'開啟檔案總管 (開啟轉換後之檔案使用)'

import subprocess

import os

import pandas as pd

#'開啟GUI 取得來源檔(準備捉取JSON之來源檔案路徑)

import tkinter as tk

from tkinter import filedialog

root = tk.Tk()


file_path = filedialog.askopenfilename(initialdir = "/",title = "Select file for JSON to csv(選擇欲處理之JSON檔案)",filetypes = (("Json files","*.json"),("Text files","*.txt"),("all files","*.*")))

df = pd.read_json (open(file_path, "r", encoding="utf8"))

print(df)  # 顯示讀取出之DataFrame資訊

input ("Press any key to continue!")


df.to_csv (r'd:\json2csv\Convert_Json_File.csv', index = None)

#將剛產出之CSV文字檔,直接開啟顯示出來

subprocess.Popen('explorer "d:\json2csv\Convert_Json_File.csv"')

2022年1月12日 星期三

正規表示式Regular Expression ( FQDN filter)

 將純文字格式下,篩選出FQDN (Domain Name名稱)

TEXTのうちドメイン名までを正規表現を用いて抽出する(FQDN)
 Regular expression which will match a valid domain name

 

背景說明:

公司因業務需要,原始來源為PDF格式,需將其內文中之FQDN網域位址,提取出來。可先經由pdftotext將PDF檔,轉換成TEXT格式後,再經由grep指令將FQDN抽出。


下列為BATCH批次檔

 
rem  將PDF檔先轉換成暫存純文字檔案
pdftotext %1 txtTempPDF.txt

rem 將PDF轉換完成為TEXT文字檔後,經由grep工具取出FQDN網域相關資訊
grep -E '[a-zA-Z0-9.\-_]{1,63}\.[a-zA-Z0-9.\-_]{1,63}' txtTempPDF.txt  -o > Tipip_FQDN.txt

rem 開啟經由grep篩選出之FQDN資訊
explorer Tipip_FQDN.txt

 

相關篩選IP參考資訊:

 (OpenSource)Pdftotext  ,PDF文字轉換工具

https://myblog-johnnyit.blogspot.com/2021/09/pdfip.html

 

2021年9月27日 星期一

PDF檔轉換成純文字檔,並抽取出IP資訊

Regular expression IPv4 addresses cover the range 0.0.0.0 to 255.255.255.255
IPv4 アドレスにマッチする正規表現

步驟一:

備妥PDF轉換成TEXT環境套裝程式

依作業系統環境,選擇下載套裝程式
https://miktex.org/download

步驟二:
安裝執行basic-miktex
備妥PDF轉換純文字程式,PDFTOTEXT

步驟三:
下列為BATCH批次檔
rem  將PDF檔先轉換成暫存純文字檔案
pdftotext %1 txtTempPDF.txt

rem 將PDF轉換完成為TEXT文字檔後,經由grep工具取出IP資訊
grep -E '[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}' txtTempPDF.txt  -o > Tipip.txt

rem 開啟經由grep篩選出之IP資訊
explorer Tipip.txt



參考資訊:
grep 過濾篩選指令

Windows環境,直接執行UnixLike指令

Utility programs (e.g. "grep") in the cygwin bash environment 相關執行檔案


2020年9月16日 星期三

auto-py-to-exe 轉換PY程式成為EXE

Step1:

安裝執行auto-py-to-exe圖形GUI界面之PYTHON轉換EXE套件程式

Step2:

將前個PYTHON程式( PYTHON旋轉PDF之程式載入),即可產出EXE執行檔


參考資訊:

auto-py-to-exe PYTHON轉換成EXE執行檔套件


2010年12月19日 星期日

Kalendar

又近年末之到來,前幾年公司有廠商會提供免費之桌曆,但近年來彷彿受到金融海嘯寒冬之影響,拿不到桌曆只好上網找資源

點選Outlook 行事曆 | 選擇列印 | 列印樣式: 週曆樣式 | 選擇開始日期與結束日期


桌曆查詢:
Wochekalendar Drucker,週曆
卓上カレンダー,桌曆
カレンダー

2010年10月21日 星期四

FreeDownloadManager續傳軟體

(開放源碼)Free Download Manager,續傳軟體,因公司需下載文件類型檔案,不管是使用Firefox/IE/Chrome,均下載不到一半時自動斷訊,安裝本軟體後,即可將下載一半自動中斷問題克服

Microsoft Download Manager,

Orbit Downloader,可自Myspace、YouTube、Imeem、Pandora、Rapidshare 等網站,進行影音檔之下載工具


相關軟體

WebPerformance網頁效能相關工具

Windows Performance Tools (WPT) Kit,效能分析


Open Web Analytics,網站分析工具


UIZE,

相關查詢:
Firebug,