Esempio n. 1
0
 def __init__(self, app=None):
     Thumbnail.__init__(self, app)
     self.overlayType = OVERLAY_ENDURANCE_THUMBNAIL
     self.__rating = 0
     self.registerForEvent(EVT_ZOOM, self._onZoom)
     self.__maxRating = 5
     self.allowDrag(True)
Esempio n. 2
0
 def get(self, key, default=None):
     """
     Access attributes of the item. If the attribute is not found
     the default value (None) will be returned.
     """
     if key.startswith('tmp:'):
         return self._beacon_tmpdata.get(key[4:], default)
     if key == 'parent':
         return self._beacon_parent
     if key == 'media':
         return self._beacon_media
     if key == 'read_only':
         # FIXME: this is not correct, a directory can also be
         # read only on a rw filesystem.
         return self._beacon_media.get('volume.read_only', default)
     if key in ('image', 'thumbnail'):
         image = self._beacon_data.get('image')
         if not image:
             if self._beacon_parent and self._beacon_id:
                 # This is not a good solution, maybe the parent is
                 # not up to date. Well, we have to live with that
                 # for now.  Only get image from parent if the item
                 # is scanned because it is a very bad idea that
                 # unscanned images (we do not know that they are
                 # images yet) inherit the image from a directory.
                 image = self._beacon_parent.get('image')
             if not image:
                 return default
         if image.startswith('http://'):
             fname = self._beacon_controller._db.md5url(image, 'images')
             if key == 'image':
                 if not os.path.isfile(fname):
                     # FIXME: We need to fetch the image. Right now this will not happen
                     # until beacon restarts or a thumbnail is requested
                     return default
                 return fname
             if key == 'thumbnail':
                 # the thumbnail code will take care of downloading
                 return Thumbnail(image, self._beacon_media)
         if key == 'image':
             return image
         if key == 'thumbnail':
             return Thumbnail(image, self._beacon_media)
     if key == 'title':
         t = self._beacon_data.get('title')
         if t:
             return t
         # generate some title and save local it for future use
         t = kaa.str_to_unicode(
             get_title(self._beacon_data['name'], self.isfile))
         self._beacon_data['title'] = t
         return t
     result = self._beacon_data.get(key, default)
     if result is None:
         return default
     return result
Esempio n. 3
0
    def _on_thumbnail(self, post_id, path, res):
        pixels = None
        width = -1
        height = -1
        try:
            image = Image.open(io.BytesIO(res.content))
            pixels = [
                item for sublist in image.convert("RGBA").getdata()
                for item in sublist
            ]
            width = image.width
            height = image.height
        except:
            self.network.get_request("%s%s" % (self.api, path),
                                     lambda res, post_id=post_id, path=path:
                                     self._on_thumbnail(post_id, path, res),
                                     None,
                                     True,
                                     True)
            return

        self.lock.acquire()
        post = self.posts[post_id]
        post.images[path] = Thumbnail(pixels, width, height)
        post_ready = True
        for key in post.images:
            if not post.images[key]:
                post_ready = False
                break
        self.lock.release()
        if post_ready:
            self._on_post_ready(post)
 def addThumbnailByInfo(self, imgPath, uri="", thumb_type=0):
     newThumb = Thumbnail(self, self.mAssignedId)
     self.mAssignedId += 1
     newThumb.setPixmap(imgPath)
     if len(uri) == 0:
         uri = imgPath
     newThumb.setUri(uri)
     newThumb.setType(thumb_type)
     self.addThumbnail(newThumb)
Esempio n. 5
0
 def get_thumbnail_attribute(self, attribute):
     """
     Return a thumbnail object for the given attribute (e.g. movie
     poster). The attribute mist be an image filename.
     """
     image = self._beacon_data.get(attribute)
     if image:
         return Thumbnail(image, self._beacon_media)
Esempio n. 6
0
class RendableWindow(Window):

    def __init__(self, wnd, target, *args, **kwargs):
        kwargs.update(wnd.__dict__)
        del kwargs['hwnd']
        super(RendableWindow, self).__init__(wnd.hwnd, *args, **kwargs)
        self.thumb = Thumbnail(target, wnd.hwnd)
        assert self.hidden == wnd.hidden

    def render(self, rc):
        self.thumb.render(rc)

    @property
    def width(self):
        return self.thumb.width

    @property
    def height(self):
        return self.thumb.height
Esempio n. 7
0
class RendableWindow(Window):

    def __init__(self, wnd, target, *args, **kwargs):
        kwargs.update(wnd.__dict__)
        del kwargs['hwnd']
        super(RendableWindow, self).__init__(wnd.hwnd, *args, **kwargs)
        self.thumb = Thumbnail(target, wnd.hwnd)
        assert self.hidden == wnd.hidden

    def render(self, rc):
        self.thumb.render(rc)

    @property
    def width(self):
        return self.thumb.width

    @property
    def height(self):
        return self.thumb.height
Esempio n. 8
0
    def __init__(self, parent=None):
        super().__init__(parent)

        self.mFullImageView = FullImageView()
        self.mFullImageView.prevRequested.connect(self.OnPrevRequested)
        self.mFullImageView.nextRequested.connect(self.OnNextRequested)

        self.mLayout = QVBoxLayout(self)
        self.mLayout.setSpacing(10)
        self.mLayout.setAlignment(Qt.AlignTop | Qt.AlignHCenter)

        self.mPresenter = Thumbnail(self)
        self.mPresenter.setFixedSize(496, 280)
        self.mPresenter.clicked.connect(self.onFullscreenView)

        self.mThumbs = ThumbView(self)
        self.mThumbs.thumbChanged.connect(self.onItemChanged)

        self.mLayout.addWidget(self.mPresenter, 0,
                               Qt.AlignCenter | Qt.AlignTop)
        self.mLayout.addWidget(self.mThumbs, 0, Qt.AlignCenter | Qt.AlignTop)
Esempio n. 9
0
 def __init__(self, wnd, target, *args, **kwargs):
     kwargs.update(wnd.__dict__)
     del kwargs['hwnd']
     super(RendableWindow, self).__init__(wnd.hwnd, *args, **kwargs)
     self.thumb = Thumbnail(target, wnd.hwnd)
     assert self.hidden == wnd.hidden
Esempio n. 10
0
 def get_thumb(self,variant="0",width=100,height=100,extension='png'):
     from thumbnail import Thumbnail
     thumb = Thumbnail(asset=self,variant=variant,width=width,height=height,extension=extension,opts=("crop",))
     thumb.ensure()
     return thumb
Esempio n. 11
0
        '--thumbnail_image',
        type=str,
        default=r'E:\jahandar\generate_dataset\images\DAPI.tif')
    parser.add_argument('--channels',
                        type=str,
                        nargs='+',
                        default=[
                            r'E:\jahandar\generate_dataset\images\IBA1.tif',
                            r'E:\jahandar\generate_dataset\images\CD31.tif',
                            r'E:\jahandar\generate_dataset\images\NeuN.tif',
                            r'E:\jahandar\generate_dataset\images\S100.tif'
                        ])
    parser.add_argument(
        '--probability_table',
        type=str,
        default=r'E:\jahandar\generate_dataset\images\probability_table.csv')
    parser.add_argument('--output_dir',
                        type=str,
                        default=r'E:\jahandar\generate_dataset\out')
    parser.add_argument('--thumbnail_downscale', type=int, default=5)

    args = parser.parse_args()

    all_images = args.channels + [args.thumbnail_image]

    if not os.path.exists(os.path.join(args.output_dir, 'memmap')):
        write_memmap(all_images, args.output_dir)
    thumbnail_box = Thumbnail(args.thumbnail_image, args.thumbnail_downscale,
                              args.channels, args.probability_table,
                              args.output_dir)
Esempio n. 12
0
 def __init__(self, wnd, target, *args, **kwargs):
     kwargs.update(wnd.__dict__)
     del kwargs['hwnd']
     super(RendableWindow, self).__init__(wnd.hwnd, *args, **kwargs)
     self.thumb = Thumbnail(target, wnd.hwnd)
     assert self.hidden == wnd.hidden
Esempio n. 13
0
 def _onSpecificInfo(self):
     """ specific info was parsed... use it here """
     if "enduranceThumbnail" in self.xmlElements:
         self.__rating = int(self.xmlElements["enduranceThumbnail"][0].attrs["rating"])
     Thumbnail._onSpecificInfo(self)
Esempio n. 14
0
 def _specificToXml(self, parent):
     s = self.doc.createElement("enduranceThumbnail")
     s.setAttribute("rating", str(self.__rating))
     parent.appendChild(s)
     Thumbnail._specificToXml(self, parent)
Esempio n. 15
0
from smtplib import SMTP
from email.mime.text import MIMEText
from email.Utils import formatdate

from captcha.image import ImageCaptcha
from thumbnail import Thumbnail
from pagination import Pagination
import config

app = Flask(__name__)
app.config.from_object(__name__)

# load default config and overwrite config from an env var
app.config.from_envvar('FLASKR_SETTINGS', silent=True)
app.config.from_object(config.AppConfig)
thumb = Thumbnail(app)


def make_dicts(cursor, row):
    return dict(
        (cursor.description[idx][0], value) for idx, value in enumerate(row))


def connect_db():
    """Connects to the specific database."""
    rv = sqlite3.connect(app.config['DATABASE'])
    rv.row_factory = make_dicts
    return rv


def get_db():
Esempio n. 16
0
class ImageView(QFrame):
    """ ImageViewer widget derived from QFrame which contains a main 
		image frame to show selected image and small thumbnail frames
	"""
    def __init__(self, parent=None):
        super().__init__(parent)

        self.mFullImageView = FullImageView()
        self.mFullImageView.prevRequested.connect(self.OnPrevRequested)
        self.mFullImageView.nextRequested.connect(self.OnNextRequested)

        self.mLayout = QVBoxLayout(self)
        self.mLayout.setSpacing(10)
        self.mLayout.setAlignment(Qt.AlignTop | Qt.AlignHCenter)

        self.mPresenter = Thumbnail(self)
        self.mPresenter.setFixedSize(496, 280)
        self.mPresenter.clicked.connect(self.onFullscreenView)

        self.mThumbs = ThumbView(self)
        self.mThumbs.thumbChanged.connect(self.onItemChanged)

        self.mLayout.addWidget(self.mPresenter, 0,
                               Qt.AlignCenter | Qt.AlignTop)
        self.mLayout.addWidget(self.mThumbs, 0, Qt.AlignCenter | Qt.AlignTop)

    def setPresenterSize(self, w, h):
        self.mPresenter.setFixedSize(w, h)
        self.mThumbs.setFixedSize(w, h)

    # sets spacing between presenter and thumbview
    def setSpacingBetween(self, spacing):
        self.mLayout.setSpacing(spacing)

    # adds a new thumbnail to thumbview
    def addThumbnail(self, pix, uri="", thumb_type=0):
        self.mThumbs.addThumbnailByInfo(pix, uri, thumb_type)
        if self.mThumbs.count() == 1:
            self.mThumbs.setActiveThumbByIndex(0)

    # this slot is called when user click on thumbnail of thumbview
    @pyqtSlot(int)
    def onItemChanged(self, id):
        imgPath, uri, thumb_type = self.mThumbs.getThumbInfo(id)
        self.mPresenter.setId(id)
        self.mPresenter.setPixmap(imgPath)
        self.mPresenter.setUri(uri)
        self.mPresenter.setType(thumb_type)

    def OnPrevRequested(self):
        self.mThumbs.prevThumb()

    def OnNextRequested(self):
        self.mThumbs.nextThumb()

    # this slot is called when user click on presenter
    @pyqtSlot()
    def onFullscreenView(self):
        if len(self.mPresenter.getImagePath()) == 0:
            return

        infolist = self.mThumbs.getThumbInfoList()
        self.mFullImageView.setInfoList(infolist)
        self.mFullImageView.setCurrentId(self.mPresenter.getId())
        self.mFullImageView.setResource(self.mPresenter.getImagePath(),
                                        self.mPresenter.getUri(),
                                        self.mPresenter.getType())
        self.mFullImageView.exec()