Hide Thumbs.jpg (1 Viewer)

toertchn

Portal Member
January 5, 2008
23
4
Home Country
Germany Germany
Started on: 2008-01-05
last update:

Summary:

Picture Viewer in MP shows thumbs.jpg as image

Description:

Would be nice if you can hide these files by default in the view.
 

toertchn

Portal Member
January 5, 2008
23
4
Home Country
Germany Germany
The tracker submission is closed - I also found the way to hide the folder.jpg in filesystem not the best.

To store folder thums in cache i modified "Core/Util/Thumbs.cs"

Code:
public static readonly string Folders = Config.GetSubFolder(Config.Dir.Thumbs, @"Folders");

public static void CreateFolders()
{
...
System.IO.Directory.CreateDirectory(Folders);
...
}

In the file "Core/Util/Util.cs" I modified 2 functions:

Code:
        public static void SetThumbnails(ref GUIListItem item)
        {
            if (item == null) return;
            string strThumb = string.Empty;

            if (!item.IsFolder || (item.IsFolder && VirtualDirectory.IsImageFile(System.IO.Path.GetExtension(item.Path).ToLower())))
            {
                if (IsPicture(item.Path)) return;

                strThumb = System.IO.Path.ChangeExtension(item.Path, ".jpg");

                if (!System.IO.File.Exists(strThumb))
                {
                    strThumb = System.IO.Path.ChangeExtension(item.Path, ".tbn");
                    if (!System.IO.File.Exists(strThumb))
                    {
                        strThumb = System.IO.Path.ChangeExtension(item.Path, ".png");
                        if (!System.IO.File.Exists(strThumb))
                        {
                            strThumb = GetThumb(item.Path);
                            if (!System.IO.File.Exists(strThumb))
                                return;
                        }
                    }
                }

                // now strThumb exists
                item.ThumbnailImage = strThumb;
                item.IconImage = strThumb;
                item.IconImageBig = strThumb;
            }
            else
            {
                if (item.Label != "..")
                {
                    strThumb = item.Path + @"\folder.jpg";
                    if (System.IO.File.Exists(strThumb))
                    {
                        item.ThumbnailImage = strThumb;
                        item.IconImage = strThumb;
                        item.IconImageBig = strThumb;
                    }
                    else
                    {
                        strThumb = String.Format(@"{0}\{1}.jpg", Thumbs.Folders, MediaPortal.Util.Utils.EncryptLine(item.Path));
                        if (System.IO.File.Exists(strThumb))
                        {
                            item.ThumbnailImage = strThumb;
                            item.IconImage = strThumb;
                            item.IconImageBig = strThumb;
                        }
                    }
                }
            }
            if (!string.IsNullOrEmpty(strThumb))
            {
                strThumb = Util.Utils.ConvertToLargeCoverArt(strThumb);
                if (System.IO.File.Exists(strThumb))
                    item.ThumbnailImage = strThumb;
            }
        }

        public static bool CreateFolderPreviewThumb(List<string> aPictureList, string aThumbPath)
        {
            bool result = false;

            if (aPictureList.Count > 0)
            {
                try
                {
                    string currentSkin = GUIGraphicsContext.Skin;

                    // when launched by configuration exe this might be the case
                    if (string.IsNullOrEmpty(currentSkin))
                    {
                        using (Profile.Settings xmlreader = new Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml")))
                        {
                            currentSkin = Application.StartupPath + @"\skin\" + xmlreader.GetValueAsString("skin", "name", "BlueTwo");
                        }
                    }

                    string defaultBackground = currentSkin + @"\media\previewbackground.png";

                    if (File.Exists(defaultBackground))
                    {
                        using (Image imgFolder = Image.FromFile(defaultBackground))
                        {
                            int width = imgFolder.Width;
                            int height = imgFolder.Height;

                            int thumbnailWidth = 256;
                            int thumbnailHeight = 256;
                            // draw a fullsize thumb if only 1 pic is available
                            if (aPictureList.Count == 1)
                            {
                                thumbnailWidth = (width - 20);
                                thumbnailHeight = (height - 20);
                            }
                            else
                            {
                                thumbnailWidth = (width - 30) / 2;
                                thumbnailHeight = (height - 30) / 2;
                            }

                            using (Bitmap bmp = new Bitmap(width, height))
                            {
                                using (Graphics g = Graphics.FromImage(bmp))
                                {
                                    g.CompositingQuality = Thumbs.Compositing;
                                    g.InterpolationMode = Thumbs.Interpolation;
                                    g.SmoothingMode = Thumbs.Smoothing;

                                    g.DrawImage(imgFolder, 0, 0, width, height);
                                    int x, y, w, h;
                                    x = 0;
                                    y = 0;
                                    w = thumbnailWidth;
                                    h = thumbnailHeight;
                                    //Load first of 4 images for the folder thumb.                  
                                    try
                                    {
                                        AddPicture(g, (string)aPictureList[0], x + 10, y + 10, w, h);
                                        System.Threading.Thread.Sleep(30);

                                        //If exists load second of 4 images for the folder thumb.
                                        if (aPictureList.Count > 1)
                                        {
                                            AddPicture(g, (string)aPictureList[1], x + thumbnailWidth + 20, y + 10, w, h);
                                            System.Threading.Thread.Sleep(30);
                                        }

                                        //If exists load third of 4 images for the folder thumb.
                                        if (aPictureList.Count > 2)
                                        {
                                            AddPicture(g, (string)aPictureList[2], x + 10, y + thumbnailHeight + 20, w, h);
                                            System.Threading.Thread.Sleep(30);
                                        }

                                        //If exists load fourth of 4 images for the folder thumb.
                                        if (aPictureList.Count > 3)
                                        {
                                            AddPicture(g, (string)aPictureList[3], x + thumbnailWidth + 20, y + thumbnailHeight + 20, w, h);
                                            System.Threading.Thread.Sleep(30);
                                        }
                                    }
                                    catch (Exception ex)
                                    {
                                        Log.Error("Utils: An exception occured creating folder preview thumb: {0}", ex.Message);
                                    }
                                }//using (Graphics g = Graphics.FromImage(bmp) )

                                try
                                {
                                    if (System.IO.File.Exists(aThumbPath))
                                        FileDelete(aThumbPath);

                                    string tmpFile = Path.Combine(Path.GetTempPath(), "folderpreview.jpg");
                                    if (System.IO.File.Exists(tmpFile))
                                        FileDelete(tmpFile);

                                    bmp.Save(tmpFile, System.Drawing.Imaging.ImageFormat.Jpeg);

                                    using (Image thumbImage = Image.FromFile(tmpFile))
                                    {
                                        string folderHash = MediaPortal.Util.Utils.EncryptLine(Path.GetDirectoryName(aThumbPath));
                                        aThumbPath = String.Format(@"{0}\{1}.jpg", Thumbs.Folders, folderHash);
                                        if (Picture.CreateThumbnail(thumbImage, aThumbPath, (int)Thumbs.ThumbResolution, (int)Thumbs.ThumbResolution, 0, true))
                                        {
                                            System.Threading.Thread.Sleep(30);
                                            // we do not want a folderL.jpg
                                            if (!aThumbPath.ToLowerInvariant().Contains(folderHash + ".jpg"))
                                            {
                                                aThumbPath = Util.Utils.ConvertToLargeCoverArt(aThumbPath);
                                                Picture.CreateThumbnail(thumbImage, aThumbPath, (int)Thumbs.ThumbLargeResolution, (int)Thumbs.ThumbLargeResolution, 0, false);
                                            }
                                        }

                                        System.Threading.Thread.Sleep(30);
                                        if (System.IO.File.Exists(aThumbPath))
                                            result = true;
                                        // File.SetAttributes(thumbnailImageName, FileAttributes.Hidden);
                                    }
                                }
                                catch (Exception ex2)
                                {
                                    Log.Error("Utils: An exception occured saving folder preview thumb: {0} - {1}", aThumbPath, ex2.Message);
                                }
                            }//using (Bitmap bmp = new Bitmap(210,210))
                        }
                    }
                    else
                        Log.Warn("Utils: Your skin does not supply previewbackground.png to create folder preview thumbs!");

                }
                catch (Exception exm)
                {
                    Log.Error("Utils: An error occured creating folder preview thumbs: {0}", exm.Message);
                }
            }  //if (pictureList.Count>0)
            else
                result = false;

            return result;
        }
 

rtv

Retired Team Member
  • Premium Supporter
  • April 7, 2005
    3,622
    301
    Osnabruck
    Home Country
    Germany Germany
    As soon as I'll find some free time I'll address that subject - either we do a dirty hack and exclude folder.jpg from being displayed in MyPictures or we do it correct - this will affect other classes like picture.cs, the folderthumbworker, etc as well.
     

    rekenaar

    Retired Team Member
  • Premium Supporter
  • December 17, 2006
    4,421
    805
    Home Country
    South Africa South Africa
    Thanks rtv. We know that you guys are very busy with important stuff like Haiti. I am still patient.
     

    codemann

    Portal Pro
    August 1, 2006
    60
    1
    Home Country
    Belgium Belgium
    Then I must be doing something wrong. In every type of view (slideshow, icons, ...) I still see the folder.jpg file.
     

    codemann

    Portal Pro
    August 1, 2006
    60
    1
    Home Country
    Belgium Belgium
    Ok, I solved the mystery. The "problem" was that my files are on a Linux Fileserver and I'm sharing it with Samba. Default Samba doesn't allow the "hidden" tag as we know it in Windows, so I had to change my Samba configuration a bit.

    For future reference (and maybe worth putting in the manual?), add this to your smb.conf for your share:

    Code:
            map hidden = yes
            create mask = 745
     

    Users who are viewing this thread

    Similar threads

    Fixed, I think. Certainly the vintage MP2 installer that I was using no longer installs the LAV filters. I can only assume that these were never part of the install package itself, but rather downloaded during the install, and that link no longer exists. Shame that the installer doesn't indicate this. Last time when I installed the...
    Fixed, I think. Certainly the vintage MP2 installer that I was using no longer installs the LAV filters. I can only assume that...
    Hi all, I've recently retired my MP2 setup for my main HTPC and gone back to separates, but I wanted to retain the ability to play...
    Replies
    4
    Views
    399
    That screen is generated by the file "MyVideo.xml", but it uses various other files too. When the list on the right is a list of episodes, the area in the middle contains the programme information for the episode that has the focus. In your screen shot, the list on the right is a list of folders. You could fill the area in the...
    That screen is generated by the file "MyVideo.xml", but it uses various other files too. When the list on the right is a list of...
    Can someone please assist me in the file name and location of which XML controls this screen. I want to create an additional box...
    Replies
    1
    Views
    1K
    maybe setting loglevel to debug might pinpoint the difference between normal and stuck? Preferable with as much disabled as possible also try to see if anything is happening during stuck for the mediaportal process(resource monitor, disk activity, cpu usage, anything) maybe other programs competing for resouces?
    maybe setting loglevel to debug might pinpoint the difference between normal and stuck? Preferable with as much disabled as...
    Since over a year my MP sometimes stucks while showing the welcome screen. It started once a week now it happens every second time...
    Replies
    4
    Views
    2K
    Depends on what you mean by the word "works". The module is quite complete and functional.
    Depends on what you mean by the word "works". The module is quite complete and functional.
    I would like one of the above IPTC metadata fields to display when viewing pictures in MP. I don't really care which, as I can...
    Replies
    3
    Views
    5K
    THX for info. 0.62 plugin version doesn't crash with MP 1.31 therefore, it seems to me to be little buggy...
    THX for info. 0.62 plugin version doesn't crash with MP 1.31 therefore, it seems to me to be little buggy...
    Started on: 2023-12-26 last update: 2023-12-26 Summary: Minimize the amount of data written to disk by simulating a tempfs RAM...
    Replies
    4
    Views
    3K
    Top Bottom