Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add heic/heif support #144

Merged
merged 4 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -331,3 +331,5 @@ ASALocalRun/
/.svn
/src/AntiDupl/AntiDupl/adExternal.h
/src/AntiDupl/AntiDupl.NET/External.cs
/src/AntiDupl/AntiDupl.NET/Form/MainForm.resx
/src/AntiDupl/AntiDupl.NET/Form/SearchExecuterForm.resx
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ And then more these collections, then more likely to have the large number of du
The natural desire of the user is to get rid of them. However, if the collection is large
enough, do this manually is a very tedious and unproductive work. AntiDupl.NET program
will help you automate this process. It can find and display duplicate images in the main
graphic formats: JPEG, GIF, TIFF, BMP, PNG, EMF, WMF, EXIF, ICON, JP2, PSD, DDS and TGA.
graphic formats: JPEG, GIF, TIFF, BMP, PNG, EMF, WMF, EXIF, ICON, JP2, PSD, DDS, HEIF, HEIC and TGA.
The comparison is based on the contents of the files, so the program can find not only
almost identical, but similar images. In addition, the program can find images with some
types of defects.
Expand Down
2 changes: 1 addition & 1 deletion src/AntiDupl/AntiDupl.NET/AntiDupl.NET.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<DefineConstants>DEBUG;TRACE</DefineConstants>
<PlatformTarget>x86</PlatformTarget>
<PlatformTarget>x64</PlatformTarget>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<OutputPath>..\..\..\bin\Debug\</OutputPath>
</PropertyGroup>
Expand Down
3 changes: 3 additions & 0 deletions src/AntiDupl/AntiDupl.NET/CoreDll.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,7 @@ public enum ImageType : int
Dds = 12,
Tga = 13,
Webp = 14,
Heif = 15,
}

public enum DefectType : int
Expand Down Expand Up @@ -288,6 +289,7 @@ public enum VersionType : int
OpenJpeg = 2,
Webp = 3,
TurboJpeg = 4,
Heif = 5,
}

public enum SelectionType : int
Expand Down Expand Up @@ -326,6 +328,7 @@ public struct adSearchOptions
public int DDS;
public int TGA;
public int WEBP;
public int HEIF;
}

[StructLayout(LayoutKind.Sequential)]
Expand Down
3 changes: 3 additions & 0 deletions src/AntiDupl/AntiDupl.NET/CoreImageInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ public string GetImageTypeString()
case CoreDll.ImageType.Dds:
builder.Append("DDS");
break;
case CoreDll.ImageType.Heif:
builder.Append("HEIF");
break;
}
return builder.ToString();
}
Expand Down
10 changes: 9 additions & 1 deletion src/AntiDupl/AntiDupl.NET/CoreSearchOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class CoreSearchOptions
private static string[] s_ddsExtensions = {"DDS"};
private static string[] s_tgaExtensions = {"TGA", "TPIC"};
private static string[] s_webpExtensions = { "WEBP" };
private static string[] s_heifExtensions = { "HEIF", "HEIC" };

public bool subFolders;
public bool system;
Expand All @@ -62,6 +63,7 @@ public class CoreSearchOptions
public bool DDS;
public bool TGA;
public bool WEBP;
public bool HEIF;

public CoreSearchOptions()
{
Expand All @@ -85,6 +87,7 @@ public CoreSearchOptions(CoreSearchOptions searchOptions)
DDS = searchOptions.DDS;
TGA = searchOptions.TGA;
WEBP = searchOptions.WEBP;
HEIF = searchOptions.HEIF;
}

public CoreSearchOptions(CoreDll.adSearchOptions searchOptions)
Expand All @@ -105,6 +108,7 @@ public CoreSearchOptions(CoreDll.adSearchOptions searchOptions)
DDS = searchOptions.DDS != CoreDll.FALSE;
TGA = searchOptions.TGA != CoreDll.FALSE;
WEBP = searchOptions.WEBP != CoreDll.FALSE;
HEIF = searchOptions.HEIF != CoreDll.FALSE;
}

public void ConvertTo(ref CoreDll.adSearchOptions searchOptions)
Expand All @@ -125,6 +129,7 @@ public void ConvertTo(ref CoreDll.adSearchOptions searchOptions)
searchOptions.DDS = DDS ? CoreDll.TRUE : CoreDll.FALSE;
searchOptions.TGA = TGA ? CoreDll.TRUE : CoreDll.FALSE;
searchOptions.WEBP = WEBP ? CoreDll.TRUE : CoreDll.FALSE;
searchOptions.HEIF = HEIF ? CoreDll.TRUE : CoreDll.FALSE;
}

public CoreSearchOptions Clone()
Expand All @@ -150,7 +155,8 @@ public bool Equals(CoreSearchOptions searchOptions)
PSD == searchOptions.PSD &&
DDS == searchOptions.DDS &&
TGA == searchOptions.TGA &&
WEBP == searchOptions.WEBP;
WEBP == searchOptions.WEBP &&
HEIF == searchOptions.HEIF;
}

public string[] GetActualExtensions()
Expand Down Expand Up @@ -182,6 +188,8 @@ public string[] GetActualExtensions()
extensions.AddRange(s_tgaExtensions);
if (WEBP)
extensions.AddRange(s_tgaExtensions);
if (HEIF)
extensions.AddRange(s_heifExtensions);
return (string[])extensions.ToArray(typeof(string));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/AntiDupl/AntiDupl.NET/Form/AboutProgramForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public AboutProgramForm(CoreLib core)

private void InitializeComponent()
{
ClientSize = new System.Drawing.Size(310, 290);
ClientSize = new System.Drawing.Size(310, 350);
FormBorderStyle = FormBorderStyle.FixedDialog;
StartPosition = FormStartPosition.CenterScreen;
ShowInTaskbar = false;
Expand Down
7 changes: 7 additions & 0 deletions src/AntiDupl/AntiDupl.NET/Form/CoreOptionsForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public class CoreOptionsForm : Form
private CheckBox m_ddsCheckBox;
private CheckBox m_tgaCheckBox;
private CheckBox m_webpCheckBox;
private CheckBox m_heifCheckBox;
private CheckBox m_searchSystemCheckBox;
private CheckBox m_searchHiddenCheckBox;

Expand Down Expand Up @@ -340,6 +341,9 @@ private void InitilizeSearchTabPage()
m_webpCheckBox = InitFactory.CheckBox.Create(OnOptionChanged);
searchFileTypeTableLayoutPanel.Controls.Add(m_webpCheckBox, 2, 3);

m_heifCheckBox = InitFactory.CheckBox.Create(OnOptionChanged);
searchFileTypeTableLayoutPanel.Controls.Add(m_heifCheckBox, 2, 4);

m_searchSystemCheckBox = InitFactory.CheckBox.Create(OnOptionChanged);
searchTableLayoutPanel.Controls.Add(m_searchSystemCheckBox, 0, 1);

Expand Down Expand Up @@ -568,6 +572,7 @@ private void GetOptions()
m_ddsCheckBox.Checked = m_newCoreOptions.searchOptions.DDS;
m_tgaCheckBox.Checked = m_newCoreOptions.searchOptions.TGA;
m_webpCheckBox.Checked = m_newCoreOptions.searchOptions.WEBP;
m_heifCheckBox.Checked = m_newCoreOptions.searchOptions.HEIF;
m_searchSystemCheckBox.Checked = m_newCoreOptions.searchOptions.system;
m_searchHiddenCheckBox.Checked = m_newCoreOptions.searchOptions.hidden;

Expand Down Expand Up @@ -621,6 +626,7 @@ private void SetOptions()
m_newCoreOptions.searchOptions.DDS = m_ddsCheckBox.Checked;
m_newCoreOptions.searchOptions.TGA = m_tgaCheckBox.Checked;
m_newCoreOptions.searchOptions.WEBP = m_webpCheckBox.Checked;
m_newCoreOptions.searchOptions.HEIF = m_heifCheckBox.Checked;
m_newCoreOptions.searchOptions.system = m_searchSystemCheckBox.Checked;
m_newCoreOptions.searchOptions.hidden = m_searchHiddenCheckBox.Checked;

Expand Down Expand Up @@ -682,6 +688,7 @@ private void UpdateStrings()
m_ddsCheckBox.Text = s.CoreOptionsForm_DdsCheckBox_Text;
m_tgaCheckBox.Text = s.CoreOptionsForm_TgaCheckBox_Text;
m_webpCheckBox.Text = s.CoreOptionsForm_WebpCheckBox_Text;
m_heifCheckBox.Text = s.CoreOptionsForm_HeifCheckBox_Text;
m_searchSystemCheckBox.Text = s.CoreOptionsForm_SearchSystemCheckBox_Text;
m_searchHiddenCheckBox.Text = s.CoreOptionsForm_SearchHiddenCheckBox_Text;

Expand Down
2 changes: 1 addition & 1 deletion src/AntiDupl/AntiDupl.NET/Form/StartFinishForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public StartFinishForm(CoreLib core, Options options)

private void InitializeComponent()
{
ClientSize = new System.Drawing.Size(310, 255);
ClientSize = new System.Drawing.Size(310, 310);
FormBorderStyle = FormBorderStyle.FixedDialog;
StartPosition = FormStartPosition.CenterScreen;
ShowInTaskbar = false;
Expand Down
4 changes: 3 additions & 1 deletion src/AntiDupl/AntiDupl.NET/GUIControl/AboutProgramPanel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private TableLayoutPanel CreateLogotype(Font font)

private Control CreateInfoTable(Font font)
{
TableLayoutPanel table = InitFactory.Layout.Create(2, 6, 0, 0);
TableLayoutPanel table = InitFactory.Layout.Create(2, 7, 0, 0);
table.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
table.ColumnStyles.Add(new ColumnStyle(SizeType.Percent, 50F));
table.CellBorderStyle = TableLayoutPanelCellBorderStyle.Inset;
Expand All @@ -127,6 +127,8 @@ private Control CreateInfoTable(Font font)
table.Controls.Add(CreateLinkLabel("libjpeg-turbo", Resources.WebLinks.LibJpegTurbo, font), 0, 5);
table.Controls.Add(CreateLabel(m_core.GetVersion(CoreDll.VersionType.TurboJpeg).ToString(), font), 1, 5);

table.Controls.Add(CreateLinkLabel("libheif", Resources.WebLinks.LibHeif, font), 0, 6);
table.Controls.Add(CreateLabel(m_core.GetVersion(CoreDll.VersionType.Heif).ToString(), font), 1, 6);
return table;
}

Expand Down
1 change: 1 addition & 0 deletions src/AntiDupl/AntiDupl.NET/Resources.cs
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,7 @@ static public class WebLinks
public const string OpenJpeg = "http://www.openjpeg.org";
public const string LibWebp = "https://github.com/webmproject/libwebp";
public const string LibJpegTurbo = "http://www.libjpeg-turbo.org";
public const string LibHeif = "http://www.libheif.org";

public static string GithubComAntiduplCurrent
{
Expand Down
1 change: 1 addition & 0 deletions src/AntiDupl/AntiDupl.NET/Strings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public Strings()
public string CoreOptionsForm_DdsCheckBox_Text;
public string CoreOptionsForm_TgaCheckBox_Text;
public string CoreOptionsForm_WebpCheckBox_Text;
public string CoreOptionsForm_HeifCheckBox_Text;
public string CoreOptionsForm_SearchSystemCheckBox_Text;
public string CoreOptionsForm_SearchHiddenCheckBox_Text;

Expand Down
1 change: 1 addition & 0 deletions src/AntiDupl/AntiDupl.NET/StringsDefaultEnglish.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ static public void CopyTo(Strings s)
s.CoreOptionsForm_DdsCheckBox_Text = "DDS";
s.CoreOptionsForm_TgaCheckBox_Text = "TGA";
s.CoreOptionsForm_WebpCheckBox_Text = "WEBP";
s.CoreOptionsForm_HeifCheckBox_Text = "HEIF";
s.CoreOptionsForm_SearchSystemCheckBox_Text = "Search system folders/files";
s.CoreOptionsForm_SearchHiddenCheckBox_Text = "Search hidden folders/files";

Expand Down
1 change: 1 addition & 0 deletions src/AntiDupl/AntiDupl.NET/StringsDefaultRussian.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ static public void CopyTo(Strings s)
s.CoreOptionsForm_DdsCheckBox_Text = "DDS";
s.CoreOptionsForm_TgaCheckBox_Text = "TGA";
s.CoreOptionsForm_WebpCheckBox_Text = "WEBP";
s.CoreOptionsForm_HeifCheckBox_Text = "HEIF";
s.CoreOptionsForm_SearchSystemCheckBox_Text = "Искать системные каталоги/файлы";
s.CoreOptionsForm_SearchHiddenCheckBox_Text = "Искать скрытые каталоги/файлы";

Expand Down
7 changes: 5 additions & 2 deletions src/AntiDupl/AntiDupl.sln
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30114.128
# Visual Studio Version 17
VisualStudioVersion = 17.2.32526.322
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "LibOpenJpeg32", "..\3rd\LibOpenJpeg\LibOpenJpeg32.vcxproj", "{1622C4EF-06A4-4DAA-9631-5D71B32858A4}"
EndProject
Expand Down Expand Up @@ -130,6 +130,9 @@ EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Vsx_64", "..\3rd\Simd\Vsx_64.vcxproj", "{7AE68C49-9959-4C22-A6D0-680BE7B5CA04}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AntiDupl.NET", "AntiDupl.NET\AntiDupl.NET.csproj", "{5E3F8B85-9C79-4EA1-90E3-BD5C84CBA820}"
ProjectSection(ProjectDependencies) = postProject
{7C8C9359-ED04-4415-BB91-9947B59BC71E} = {7C8C9359-ED04-4415-BB91-9947B59BC71E}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
5 changes: 5 additions & 0 deletions src/AntiDupl/AntiDupl/AntiDupl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@

#include "TurboJpeg/inc/jconfig.h"

#include "libheif\heif.h"

#include <windows.h>

namespace ad
Expand Down Expand Up @@ -112,6 +114,9 @@ DLLAPI adError adVersionGet(adVersionType versionType, adCharA * pVersion, adSiz
case AD_VERSION_TYPE_TURBOJPEG:
version = AD_STRINGIFY(LIBJPEG_TURBO_VERSION);
break;
case AD_VERSION_TYPE_LIBHEIF:
version = heif_get_version();
break;
default:
return AD_ERROR_INVALID_VERSION_TYPE;
}
Expand Down
3 changes: 3 additions & 0 deletions src/AntiDupl/AntiDupl/AntiDupl.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ extern "C"
AD_IMAGE_DDS = 12,
AD_IMAGE_TGA = 13,
AD_IMAGE_WEBP = 14,
AD_IMAGE_HEIF = 15,
AD_IMAGE_SIZE
};

Expand Down Expand Up @@ -363,6 +364,7 @@ extern "C"
AD_VERSION_TYPE_OPENJPEG = 2,
AD_VERSION_TYPE_WEBP = 3,
AD_VERSION_TYPE_TURBOJPEG = 4,
AD_VERSION_TYPE_LIBHEIF = 5,
AD_VERSION_TYPE_SIZE
};

Expand Down Expand Up @@ -403,6 +405,7 @@ extern "C"
adBool DDS;
adBool TGA;
adBool WEBP;
adBool HEIF;
};
typedef adSearchOptions* adSearchOptionsPtr;

Expand Down
3 changes: 3 additions & 0 deletions src/AntiDupl/AntiDupl/AntiDupl32.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<ProjectGuid>{7C8C9359-ED04-4415-BB91-9947B59BC71E}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<ProjectName>AntiDupl32</ProjectName>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<PropertyGroup Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
Expand Down Expand Up @@ -57,6 +58,7 @@
<ClCompile Include="adFileStream.cpp" />
<ClCompile Include="adFileUtils.cpp" />
<ClCompile Include="adGdiplus.cpp" />
<ClCompile Include="adHeif.cpp" />
<ClCompile Include="adHintSetter.cpp" />
<ClCompile Include="adImage.cpp" />
<ClCompile Include="adImageComparer.cpp" />
Expand Down Expand Up @@ -106,6 +108,7 @@
<ClInclude Include="adFileStream.h" />
<ClInclude Include="adFileUtils.h" />
<ClInclude Include="adGdiplus.h" />
<ClInclude Include="adHeif.h" />
<ClInclude Include="adHintSetter.h" />
<ClInclude Include="adImage.h" />
<ClInclude Include="adImageComparer.h" />
Expand Down
6 changes: 6 additions & 0 deletions src/AntiDupl/AntiDupl/AntiDupl32.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
<ClCompile Include="adFileInfo.cpp">
<Filter>Files</Filter>
</ClCompile>
<ClCompile Include="adHeif.cpp">
<Filter>Image</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="adBlurringDetector.h" />
Expand Down Expand Up @@ -146,6 +149,9 @@
<ClInclude Include="adFileInfo.h">
<Filter>Files</Filter>
</ClInclude>
<ClInclude Include="adHeif.h">
<Filter>Image</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Image">
Expand Down
2 changes: 2 additions & 0 deletions src/AntiDupl/AntiDupl/AntiDupl64.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
<ClCompile Include="adFileStream.cpp" />
<ClCompile Include="adFileUtils.cpp" />
<ClCompile Include="adGdiplus.cpp" />
<ClCompile Include="adHeif.cpp" />
<ClCompile Include="adHintSetter.cpp" />
<ClCompile Include="adImage.cpp" />
<ClCompile Include="adImageComparer.cpp" />
Expand Down Expand Up @@ -107,6 +108,7 @@
<ClInclude Include="adFileStream.h" />
<ClInclude Include="adFileUtils.h" />
<ClInclude Include="adGdiplus.h" />
<ClInclude Include="adHeif.h" />
<ClInclude Include="adHintSetter.h" />
<ClInclude Include="adImage.h" />
<ClInclude Include="adImageComparer.h" />
Expand Down
6 changes: 6 additions & 0 deletions src/AntiDupl/AntiDupl/AntiDupl64.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
<ClCompile Include="adIniFile.cpp">
<Filter>Files</Filter>
</ClCompile>
<ClCompile Include="adHeif.cpp">
<Filter>Image</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="adBlurringDetector.h" />
Expand Down Expand Up @@ -146,6 +149,9 @@
<ClInclude Include="adIO.h">
<Filter>Files</Filter>
</ClInclude>
<ClInclude Include="adHeif.h">
<Filter>Image</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Filter Include="Image">
Expand Down
9 changes: 8 additions & 1 deletion src/AntiDupl/AntiDupl/adDataCollector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,14 @@ namespace ad
pImageData->type = (TImageType)pImage->Format();

TView gray(pImage->View()->width, pImage->View()->height, TView::Gray8, NULL);
Simd::BgraToGray(*pImage->View(), gray);
if (pImage->View()->format == TView::Format::Rgb24)
{
Simd::RgbToGray(*pImage->View(), gray);
}
else
{
Simd::BgraToGray(*pImage->View(), gray);
}

pImageData->blockiness = GetBlockiness(gray);

Expand Down
Loading