mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-02 18:26:27 +13:00
fixed issue #125 Uploading GIF is supported by copying image
added @Rainbowed code upload Gif from URL embedded in image
This commit is contained in:
parent
bf2abc4cc4
commit
37b6f5a821
2 changed files with 24 additions and 2 deletions
|
@ -89,7 +89,7 @@ public IEnumerable<Image> GetImageEnumerator()
|
|||
{
|
||||
if (index.Location > int.MaxValue || index.Length > int.MaxValue)
|
||||
{
|
||||
MessageBox.Show("Cache file size can't exceed 2.14 GB.\r\nPlease use FFmpeg screen recording instead of GIF.", "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
MessageBox.Show("Cache file size cannot exceed 2.00 GiB.\r\nPlease use FFmpeg screen recording instead of GIF.", "ShareX", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
||||
yield break;
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@ You should have received a copy of the GNU General Public License
|
|||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Windows.Forms;
|
||||
using UploadersLib;
|
||||
|
||||
|
@ -143,11 +144,32 @@ public static void IndexFolder(string folderPath, TaskSettings taskSettings = nu
|
|||
}
|
||||
}
|
||||
|
||||
public static bool ClipboardUploadGif(TaskSettings taskSettings)
|
||||
{
|
||||
IDataObject clipboardData = Clipboard.GetDataObject();
|
||||
if (clipboardData != null && clipboardData.GetDataPresent(DataFormats.Html))
|
||||
{
|
||||
String data = clipboardData.GetData(DataFormats.Html).ToString();
|
||||
Match match = Regex.Match(data, @"<!--StartFragment--><img.*?src=""(.*?)"".*?><!--EndFragment-->");
|
||||
if (match.Success)
|
||||
{
|
||||
String url = match.Groups[1].Value;
|
||||
if (Helpers.GetProperExtension(Helpers.GetURLFilename(url)) == "gif")
|
||||
{
|
||||
string filename = Helpers.GetURLFilename(url);
|
||||
DownloadAndUploadFile(url, filename, taskSettings);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void ClipboardUpload(TaskSettings taskSettings = null)
|
||||
{
|
||||
if (taskSettings == null) taskSettings = TaskSettings.GetDefaultTaskSettings();
|
||||
|
||||
if (Clipboard.ContainsImage())
|
||||
if (Clipboard.ContainsImage() && !ClipboardUploadGif(taskSettings))
|
||||
{
|
||||
Image img = Clipboard.GetImage();
|
||||
|
||||
|
|
Loading…
Reference in a new issue