2024 年 PHP Conference Japan

Imagick::stripImage

(PECL imagick 2, PECL imagick 3)

Imagick::stripImage移除影像的所有設定檔和註解

說明

public Imagick::stripImage(): bool

移除影像的所有設定檔和註解。

參數

此函式沒有參數。

傳回值

成功時傳回 true

錯誤/例外

發生錯誤時拋出 ImagickException。

新增筆記

使用者貢獻的筆記 3 則筆記

Max Eremin
7 年前
StripImage 預設也會刪除 ICC 圖像設定檔。
產生的圖像似乎會遺失許多色彩資訊,與未移除設定檔的版本相比,看起來「扁平」。

請考慮在移除所有其他 EXIF 資料的同時保留 ICC 設定檔(這會產生更豐富的色彩)

1. 提取 ICC 設定檔
2. 移除 EXIF 資料和圖像設定檔
3. 將 ICC 設定檔加回來

程式碼如下
<?php
$profiles
= $img->getImageProfiles("icc", true);

$img->stripImage();

if(!empty(
$profiles))
$img->profileImage("icc", $profiles['icc']);
?>
g dot a dot karthikeyan at gmail dot com
10 年前
請注意,移除 EXIF 資訊而不處理 EXIF 中的方位資訊將導致圖像方位錯誤
pengc99
13 年前
這實際上會清除 EXIF 資料,因此如果您執行具有隱私疑慮的圖像上傳腳本,這將有效清除圖像中的所有 GPS/詮釋資料。
To Top