Ejemplo n.º 1
0
    def OnImportPics(self, event):
        dlg = wx.FileDialog(self, _("Import images"),
                            Settings().GetImagePath(), "",
                            _("Image files") + " (*.*)|*.*",
                            wx.FD_OPEN | wx.FD_MULTIPLE | wx.FD_PREVIEW)
        if dlg.ShowModal() == wx.ID_OK:
            pics = []
            for path in dlg.GetPaths():
                if not self._CheckImportedPic(path):
                    continue

                pic = Picture(path)
                pics.append(pic)
                ImageCache().RegisterPicture(pic)

            selItms = self.lvPics.GetSelected()
            self.InsertPictures(pics,
                                selItms[0] + 1 if selItms else None,
                                autopath=True)

            Settings().SetImagePath(os.path.dirname(path))

            selPics = self.lvPics.GetSelectedPictures()
            self.pnlEditPicture.SetPictures(selPics)
        dlg.Destroy()
Ejemplo n.º 2
0
    def OnDropFiles(self, x, y, filenames):
        itm = self.pnlPfs.lvPics.HitTest((x, y))
        logging.debug("OnDropFiles(%d, %d, %s): %s", x, y, filenames, itm)

        pics = []
        for path in filenames:
            ext = os.path.splitext(path)[1].lower()
            if ext in ['.jpg', '.jpeg', '.png', '.bmp']:
                pic = Picture(path)
                pics.append(pic)

        if pics:
            self.pnlPfs.InsertPictures(
                pics, itm + 1 if itm != wx.NOT_FOUND else None, True)
            return True
        return False
Ejemplo n.º 3
0
    def OnImportPics(self, event):
        dlg = wx.FileDialog(self, _(u"Import images"),
                            Settings().GetImagePath(), "",
                            _(u"Imagefiles") + " (*.*)|*.*",
                            wx.FD_OPEN | wx.FD_MULTIPLE | wx.FD_PREVIEW)
        if dlg.ShowModal() == wx.ID_OK:
            pics = []
            for path in dlg.GetPaths():

                if self.__project.GetTimelapse():
                    picPattern = PicturePattern.Create(path)
                    if not picPattern.IsOk():
                        dlgErr = wx.MessageDialog(
                            self,
                            _(u"Filename '%s' does not match a number pattern "
                              u"which is necessary for a time lapse slide "
                              u"show!") % path, _(u"Error"),
                            wx.OK | wx.ICON_ERROR)
                        dlgErr.ShowModal()
                        dlgErr.Destroy()
                        continue

                pic = Picture(path)
                pics.append(pic)
                ImageCache().RegisterPicture(pic)

            selItms = self.lvPics.GetSelected()
            self.InsertPictures(pics,
                                selItms[0] + 1 if selItms else None,
                                autopath=True)

            Settings().SetImagePath(os.path.dirname(path))

            selPics = self.lvPics.GetSelectedPictures()
            self.pnlEditPicture.SetPictures(selPics)
        dlg.Destroy()
Ejemplo n.º 4
0
def testWrite():
    from photofilmstrip.core.Picture import Picture
    p1 = Picture(None)
    p1.SetComment("this is my first picture")
    p1.SetDuration(7)

    p2 = Picture(None)
    p2.SetComment("this is my second picture")
    p2.SetDuration(12)

    p3 = Picture(None)
    p3.SetComment("this is my third picture")
    p3.SetDuration(2)

    s = SubtitleSrt(".")
    s.Start([p1, p2, p3])
Ejemplo n.º 5
0
    def Load(self, importPath=None):
        filename = self._filename
        if not os.path.isfile(filename):
            return False

        self.__Connect()
        cur = self.__GetCursor()

        fileRev = 1
        try:
            # at the beginning we had no property table
            cur.execute("SELECT value FROM `property` WHERE name=?", ("rev",))
            result = cur.fetchone()
            if result:
                fileRev = int(result[0])
        except sqlite3.DatabaseError:
            pass

        try:
            cur.execute("SELECT * FROM `picture`")
        except sqlite3.DatabaseError:
            self.__Close()
            return False

        picList = []
        for row in cur:
            imgFile = row["filename"]
            imgPath = os.path.dirname(imgFile)
            self._StepProgress(_(u"Loading '%s' ...") % (os.path.basename(imgFile)))

            picData = self.__LoadSafe(row, 'data', None)
            if picData is None:
                if not (os.path.exists(imgPath) and os.path.isfile(imgFile)):
                    if imgPath not in self.__altPaths:
                        self._SelectAlternatePath(imgPath)

                    imgFile = os.path.join(self.__altPaths.get(imgPath, imgPath),
                                           os.path.basename(imgFile))

                pic = Picture(imgFile)

            else:
                if importPath is None:
                    importPath = os.path.dirname(filename)

                tmpImg = os.path.join(importPath, os.path.basename(imgFile))
                if os.path.isfile(tmpImg):
                    logging.debug('overwrite existing file: %s', tmpImg)

                if not os.path.isdir(importPath):
                    os.makedirs(importPath)

                fd = open(tmpImg, 'wb')
                fd.write(picData)
                fd.close()
                pic = Picture(tmpImg)

            pic.SetWidth(self.__LoadSafe(row, 'width', -1))
            pic.SetHeight(self.__LoadSafe(row, 'height', -1))
            rect = (row["start_left"], row["start_top"], row["start_width"], row["start_height"])
            pic.SetStartRect(rect)
            rect = (row["target_left"], row["target_top"], row["target_width"], row["target_height"])
            pic.SetTargetRect(rect)
            pic.SetDuration(row["duration"])
            pic.SetMovement(self.__LoadSafe(row, "movement", Picture.MOVE_LINEAR))
            pic.SetComment(row["comment"])
            pic.SetRotation(row['rotation'])
            pic.SetEffect(self.__LoadSafe(row, 'effect', Picture.EFFECT_NONE))

            pic.SetTransition(self.__LoadSafe(row, 'transition', Picture.TRANS_FADE))
            pic.SetTransitionDuration(self.__LoadSafe(row, 'transition_duration', 1.0))

            self.__LoadThumbnail(pic, row["picture_id"])

            picList.append(pic)

        project = Project(self._filename)
        project.SetPictures(picList)
        if fileRev >= 2:
            project.SetAudioFiles(self.__LoadProperties(cur, "audiofile", str))
            project.SetDuration(self.__LoadProperty(cur, "duration", float))
            project.SetAspect(self.__LoadProperty(cur, "aspect", str, Aspect.ASPECT_16_9))
            project.SetTimelapse(self.__LoadProperty(cur, "timelapse", int, False))

        self.__Close()

        self._project = project
        return True
Ejemplo n.º 6
0
def testWrite():
    from photofilmstrip.core.Picture import Picture
    p1 = Picture(None)
    p1.SetComment("this is my first picture")
    p1.SetDuration(25)

    p2 = Picture(None)
    p2.SetComment("this is my second picture")
    p2.SetDuration(10)

    p3 = Picture(None)
    p3.SetComment("this is my third picture")
    p3.SetDuration(20)

    p4 = Picture(None)
    p4.SetComment("this is my third picture")
    p4.SetDuration(3740)

    s = SubtitleSrt("output")
    s.Start([p1, p2, p3, p4])