图片的特征哈希值怎么修改?
图片的特征哈希值怎么修改?
图片的特征哈希值怎么修改?
将图片修改下,它的 hash 值自然就变了,比如转换、压缩、改变大小等
可以从3种方面考虑:
Windows平台 图片批量添加水印工具 ImageMagick
:
http://www.imagemagick.org/script/download.php
一:描述:哈希值操作
1、数据保存多张图片的地址,如果没有就是0;
2、获取当前的哈希值,并设置当前的图片
3、每点击一下图片就会换下一张并修改哈希值
<body>
<img src="images/1.jpg" id="img1"/>
<script type="text/javascript">
//哈希值
// window.location.hash=3;
// var hash=window.location.hash;
// console.log(hash.substring(1));
var img=document.getElementById('img1');
img.οnclick=function(){
var hash=window.location.hash.substring(1);
console.log(hash);
if(hash=='')
{
hash=1;
window.location.hash=1;
}
hash=parseInt(hash); //转换为number类型
// console.log(typeof hash);
//换图片
hash++;
if(hash>5)hash=1;
window.location.hash=hash;
img.src='images/'+hash+'.jpg'
}
</script>
</body>
这是大多用户修改图片hash值的方法,供你参考:
1、安装homebrew:
Homebrew的安装很简单,只需在终端下输入如下指令:
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
2、安装imagemagick
brew install imagemagick
3、使用 ImageMagick 对 png 图片做轻量压缩,及不损失图片质量,又可改变图片文件 hash 值。方法:
1.切换cd至工程目录你自己的工程目录
2.执行,命令
>find . -iname "*.png" -exec echo {} \; -exec convert {} {} \;
打开图片,使用opencv对图片进行高斯滤波,去噪处理。然后图片HASH也就变了。
import cv2
# 读取图片
img = cv2.imread('test.png')
# 高斯滤波5x5降噪
result = cv2.GaussianBlur(img, (5, 5), 0)
# 显示结果
cv2.imshow('origion', img)
cv2.imshow('filtered', result)
#保存图片
cv2.imwrite("dst.png", result)
cv2.waitKey(0)
下边是C++版本代码
#include <opencv2\opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
Mat img = imread("test.png");
if (img.empty())
{
cout << "打开图片失败" << endl;
return -1;
}
Mat result;
// 高斯滤波5x5降噪
GaussianBlur(img, result, Size(5, 5), 0, 0);
//显示原图像
imshow("origion", img);
//显示去噪后的图像
imshow("filtered", result);
imwrite("dst.png", result);
waitKey(0);
return 0;
}