`
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-"""
-
-from os.path import exists
-
-from PyQt5.QtGui import (QIcon)
-from PyQt5.QtCore import (Qt, QSize)
-from PyQt5.QtWidgets import (
- QGridLayout, QHBoxLayout, QWidget, QTabWidget, QPushButton)
-
-from utils.config import config
-
-
-class RibbonTab(QWidget):
-
- def __init__(self, parent=None, funcs=None, tracker=None, tabName=""):
- super(QWidget, self).__init__()
- self.parent = parent
- self.tracker = tracker
- self.tabName = tabName
-
- self.buttonList = []
- self.layout = QHBoxLayout(self)
- self.layout.setAlignment(Qt.AlignLeft)
-
- self.initButtons(funcs)
-
- def initButtons(self, funcs):
-
- for funcName, funcConfig in funcs.items():
- self.loadButtonConfig(funcName, funcConfig)
- self.layout.addWidget(self.buttonList[-1],
- alignment=getattr(Qt, funcConfig["align"]))
- self.layout.addStretch()
- self.layout.addWidget(PageNavigator(self.parent))
-
- def loadButtonConfig(self, buttonName, buttonConfig):
-
- w = self.parent.frameGeometry().height(
- )*config["TBAR_ISIZE_REL"]*buttonConfig["iconW"]
- h = self.parent.frameGeometry().height(
- )*config["TBAR_ISIZE_REL"]*buttonConfig["iconH"]
- m = config["TBAR_ISIZE_MARGIN"]
-
- icon = QIcon()
- path = config["TBAR_ICONS"] + buttonConfig["path"]
- if (exists(path)):
- icon = QIcon(path)
- else:
- icon = QIcon(config["TBAR_ICON_DEFAULT"])
-
- self.buttonList.append(QPushButton(self))
- self.buttonList[-1].setObjectName(buttonName)
-
- self.buttonList[-1].setIcon(icon)
- self.buttonList[-1].setIconSize(QSize(w, h))
- self.buttonList[-1].setFixedSize(QSize(w*m, h*m))
-
- tooltip = f"{buttonConfig['helpTitle']}\
-
{buttonConfig['helpMsg']}
"
- self.buttonList[-1].setToolTip(tooltip)
- self.buttonList[-1].setCheckable(buttonConfig["toggle"])
-
- if hasattr(self.parent, buttonName):
- self.buttonList[-1].clicked.connect(
- getattr(self.parent, buttonName))
- else:
- self.buttonList[-1].clicked.connect(
- getattr(self.parent, 'poricomNoop'))
-
-
-class PageNavigator(RibbonTab):
-
- def __init__(self, parent=None, tracker=None):
- super(QWidget, self).__init__()
- self.parent = parent
- self.tracker = tracker
- self.buttonList = []
-
- self.layout = QGridLayout(self)
- self.layout.setContentsMargins(0, 0, 0, 0)
- for funcName, funcConfig in config["MODE_FUNCS"].items():
- self.loadButtonConfig(funcName, funcConfig)
-
- self.layout.addWidget(self.buttonList[0], 0, 0, 1, 1)
- self.layout.addWidget(self.buttonList[1], 1, 0, 1, 1)
- self.layout.addWidget(self.buttonList[2], 0, 1, 1, 2)
- self.layout.addWidget(self.buttonList[3], 1, 1, 1, 1)
- self.layout.addWidget(self.buttonList[4], 1, 2, 1, 1)
-
-
-class Ribbon(QTabWidget):
- def __init__(self, parent=None, tracker=None):
- super(QTabWidget, self).__init__(parent)
- self.parent = parent
- self.tracker = tracker
-
- h = self.parent.frameGeometry().height(
- ) * config["TBAR_ISIZE_REL"] * config["RBN_HEIGHT"]
- self.setFixedHeight(h)
-
- for tabName, tools in config["TBAR_FUNCS"].items():
- self.addTab(RibbonTab(parent=self.parent, funcs=tools,
- tracker=self.tracker, tabName=tabName), tabName)
diff --git a/code/Trackers.py b/code/Trackers.py
deleted file mode 100644
index aebbee7..0000000
--- a/code/Trackers.py
+++ /dev/null
@@ -1,176 +0,0 @@
-"""
-Poricom State-Tracking Logic
-
-Copyright (C) `2021-2022` ``
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-"""
-
-from os.path import isfile, join, splitext, normpath, abspath, exists, dirname
-from os import listdir
-
-from PyQt5.QtGui import QPixmap, QPainter
-
-from utils.config import config
-
-
-class Tracker:
-
- def __init__(self, filename=config["HOME_IMAGE"], filenext=config["ABOUT_IMAGE"]):
- if not config["SPLIT_VIEW_MODE"]:
- self._pixImage = PImage(filename)
- if config["SPLIT_VIEW_MODE"]:
- splitImage = self.twoFileToImage(filename, filenext)
- self._pixImage = PImage(splitImage, filename)
- self._pixMask = PImage(filename)
-
- self._filepath = abspath(dirname(filename))
- self._writeMode = False
-
- self._imageList = []
-
- self._language = "jpn"
- self._orientation = "_vert"
-
- self._betterOCR = False
- self._ocrModel = None
-
- def twoFileToImage(self, fileLeft, fileRight):
- imageLeft, imageRight = PImage(fileLeft), PImage(fileRight)
- if not (imageLeft.isValid()):
- return
-
- w = imageLeft.width() + imageRight.width()
- h = max(imageLeft.height(), imageRight.height())
- if imageRight.isNull():
- w = imageLeft.width() * 2
- h = imageLeft.height()
- splitImage = QPixmap(w, h)
- painter = QPainter(splitImage)
- painter.drawPixmap(0, 0, imageLeft.width(), imageLeft.height(),
- imageLeft)
- painter.drawPixmap(imageLeft.width(), 0, imageRight.width(),
- imageRight.height(), imageRight)
- painter.end()
-
- return splitImage
-
- @property
- def pixImage(self):
- return self._pixImage
-
- @pixImage.setter
- def pixImage(self, image):
- if (type(image) is str and PImage(image).isValid()):
- self._pixImage = PImage(image)
- self._pixImage.filename = abspath(image)
- self._filepath = abspath(dirname(image))
- if (type(image) is tuple):
- fileLeft, fileRight = image
- if not fileRight:
- if fileLeft:
- self._pixImage = PImage(fileLeft)
- self._pixImage.filename = abspath(fileLeft)
- self._filepath = abspath(dirname(fileLeft))
- return
- splitImage = self.twoFileToImage(fileLeft, fileRight)
-
- self._pixImage = PImage(splitImage, fileLeft)
- self._pixImage.filename = abspath(fileLeft)
- self._filepath = abspath(dirname(fileLeft))
-
- @property
- def pixMask(self):
- return self._pixMask
-
- @pixMask.setter
- def pixMask(self, image):
- self._pixMask = image
-
- @property
- def filepath(self):
- return self._filepath
-
- @filepath.setter
- def filepath(self, filepath):
- self._filepath = filepath
- filelist = filter(lambda f: isfile(join(self.filepath,
- f)), listdir(self.filepath))
- self._imageList = list(map(lambda p: normpath(join(self.filepath, p)), filter(
- (lambda f: ('*'+splitext(f)[1]) in config["IMAGE_EXTENSIONS"]), filelist)))
-
- @property
- def language(self):
- return self._language
-
- @language.setter
- def language(self, language):
- self._language = language
-
- @property
- def orientation(self):
- return self._orientation
-
- @orientation.setter
- def orientation(self, orientation):
- self._orientation = orientation
-
- @property
- def ocrModel(self):
- return self._ocrModel
-
- @ocrModel.setter
- def ocrModel(self, ocrModel):
- self._ocrModel = ocrModel
-
- @property
- def writeMode(self):
- return self._writeMode
-
- @writeMode.setter
- def writeMode(self, writeMode):
- self._writeMode = writeMode
-
- def switchWriteMode(self):
- self._writeMode = not self._writeMode
- return self._writeMode
-
- def switchOCRMode(self):
- self._betterOCR = not self._betterOCR
- return self._betterOCR
-
-
-class PImage(QPixmap):
-
- def __init__(self, *args):
- super(QPixmap, self).__init__(args[0])
-
- # Current directory + filename
- if type(args[0]) == str:
- self._filename = args[0]
- if type(args[0]) == QPixmap:
- self._filename = args[1]
- # Current directory
- self._filepath = None
-
- @property
- def filename(self):
- return self._filename
-
- @filename.setter
- def filename(self, filename):
- self._filename = filename
-
- def isValid(self):
- return exists(self._filename) and isfile(self._filename)
diff --git a/code/Views.py b/code/Views.py
deleted file mode 100644
index bef47b1..0000000
--- a/code/Views.py
+++ /dev/null
@@ -1,267 +0,0 @@
-"""
-Poricom View Components
-
-Copyright (C) `2021-2022` ``
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-"""
-
-from time import sleep
-
-from PyQt5.QtCore import (Qt, QRectF, QTimer, QThreadPool, pyqtSlot)
-from PyQt5.QtCore import (Qt, QRect, QSize, QRectF,
- QTimer, QThreadPool, pyqtSlot)
-from PyQt5.QtWidgets import (
- QApplication, QGraphicsView, QGraphicsScene, QLabel)
-
-from Workers import BaseWorker
-from utils.image_io import logText, pixboxToText
-
-
-class BaseCanvas(QGraphicsView):
-
- def __init__(self, parent=None, tracker=None):
- super(QGraphicsView, self).__init__(parent)
- self.parent = parent
- self.tracker = tracker
-
- self.timer_ = QTimer()
- self.timer_.setInterval(300)
- self.timer_.setSingleShot(True)
- self.timer_.timeout.connect(self.rubberBandStopped)
-
- self.canvasText = QLabel("", self, Qt.WindowStaysOnTopHint)
- self.canvasText.setWordWrap(True)
- self.canvasText.hide()
- self.canvasText.setObjectName("canvasText")
-
- self.scene = QGraphicsScene()
- self.setScene(self.scene)
- self.pixmap = self.scene.addPixmap(self.tracker.pixImage.scaledToWidth(
- self.viewport().geometry().width(), Qt.SmoothTransformation))
-
- self.setDragMode(QGraphicsView.RubberBandDrag)
-
- def mouseMoveEvent(self, event):
- rubberBandVisible = not self.rubberBandRect().isNull()
- if (event.buttons() & Qt.LeftButton) and rubberBandVisible:
- self.timer_.start()
- QGraphicsView.mouseMoveEvent(self, event)
-
- def mouseReleaseEvent(self, event):
- logPath = self.tracker.filepath + "/log.txt"
- logToFile = self.tracker.writeMode
- text = self.canvasText.text()
- logText(text, mode=logToFile, path=logPath)
- self.canvasText.hide()
- super().mouseReleaseEvent(event)
-
- @pyqtSlot()
- def rubberBandStopped(self):
-
- if (self.canvasText.isHidden()):
- self.canvasText.setText("")
- self.canvasText.adjustSize()
- self.canvasText.show()
-
- lang = self.tracker.language + self.tracker.orientation
- pixbox = self.grab(self.rubberBandRect())
-
- worker = BaseWorker(pixboxToText, pixbox, lang, self.tracker.ocrModel)
- worker.signals.result.connect(self.canvasText.setText)
- worker.signals.finished.connect(self.canvasText.adjustSize)
- self.timer_.timeout.disconnect(self.rubberBandStopped)
- worker.signals.finished.connect(
- lambda: self.timer_.timeout.connect(self.rubberBandStopped))
- QThreadPool.globalInstance().start(worker)
-
-
-class FullScreen(BaseCanvas):
-
- def __init__(self, parent=None, tracker=None):
- super().__init__(parent, tracker)
- self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
- self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
-
- def takeScreenshot(self):
- screen = QApplication.primaryScreen()
- s = screen.size()
- self.pixmap.setPixmap(screen.grabWindow(
- 0).scaled(s.width(), s.height()))
- self.scene.setSceneRect(QRectF(self.pixmap.pixmap().rect()))
-
- def mouseReleaseEvent(self, event):
- BaseCanvas.mouseReleaseEvent(self, event)
- self.parent.close()
-
-
-class OCRCanvas(BaseCanvas):
-
- def __init__(self, parent=None, tracker=None):
- super().__init__(parent, tracker)
-
- self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
- self.setHorizontalScrollBarPolicy(Qt.ScrollBarAsNeeded)
-
- self._viewImageMode = parent.config["VIEW_IMAGE_MODE"]
- self._splitViewMode = parent.config["SPLIT_VIEW_MODE"]
- self._zoomPanMode = False
- self.currentScale = 1
-
- self._scrollAtMin = 0
- self._scrollAtMax = 0
- self._trackPadAtMin = 0
- self._trackPadAtMax = 0
- self._scrollSuppressed = False
-
- self.scene = QGraphicsScene()
- self.setScene(self.scene)
- self.pixmap = self.scene.addPixmap(self.tracker.pixImage.scaledToWidth(
- self.viewport().geometry().width(), Qt.SmoothTransformation))
-
- def viewImage(self, factor=1):
- # self.verticalScrollBar().setSliderPosition(0)
- factor = self.currentScale
- w = factor*self.viewport().geometry().width()
- h = factor*self.viewport().geometry().height()
- if self._viewImageMode == 0:
- self.pixmap.setPixmap(
- self.tracker.pixImage.scaledToWidth(w, Qt.SmoothTransformation))
- elif self._viewImageMode == 1:
- self.pixmap.setPixmap(
- self.tracker.pixImage.scaledToHeight(h, Qt.SmoothTransformation))
- elif self._viewImageMode == 2:
- self.pixmap.setPixmap(self.tracker.pixImage.scaled(
- w, h, Qt.KeepAspectRatio, Qt.SmoothTransformation))
- self.scene.setSceneRect(QRectF(self.pixmap.pixmap().rect()))
-
- def setViewImageMode(self, mode):
- self._viewImageMode = mode
- self.parent.config["VIEW_IMAGE_MODE"] = mode
- self.parent.config["SELECTED_INDEX"]['imageScaling'] = mode
- self.viewImage()
-
- def splitViewMode(self):
- return self._splitViewMode
-
- def toggleSplitView(self):
- self._splitViewMode = not self._splitViewMode
- self.parent.config["SPLIT_VIEW_MODE"] = self._splitViewMode
-
- def zoomView(self, isZoomIn, usingButton=False):
- factor = 1.1
- if usingButton:
- factor = 1.4
-
- if isZoomIn and self.currentScale < 15:
- #self.scale(factor, factor)
- self.currentScale *= factor
- self.viewImage(self.currentScale)
- elif not isZoomIn and self.currentScale > 0.35:
- #self.scale(1/factor, 1/factor)
- self.currentScale /= factor
- self.viewImage(self.currentScale)
-
- def toggleZoomPanMode(self):
- self._zoomPanMode = not self._zoomPanMode
-
- def resizeEvent(self, event):
- self.viewImage()
- QGraphicsView.resizeEvent(self, event)
-
- def wheelEvent(self, event):
- pressedKey = QApplication.keyboardModifiers()
- zoomMode = pressedKey == Qt.ControlModifier or self._zoomPanMode
-
- # self.setTransformationAnchor(QGraphicsView.AnchorUnderMouse)
- if zoomMode:
- if event.angleDelta().y() > 0:
- isZoomIn = True
- elif event.angleDelta().y() < 0:
- isZoomIn = False
- scenePos = self.mapToScene(event.pos())
- truePos = QRect(scenePos.toPoint(), QSize(2, 2)).center()
- self.centerOn(truePos)
- self.zoomView(isZoomIn)
-
- if self._scrollSuppressed:
- return
-
- if not zoomMode:
-
- mouseScrollLimit = 3
- trackpadScrollLimit = 36
- wheelDelta = 120
-
- def suppressScroll():
- self._scrollSuppressed = True
- worker = BaseWorker(sleep, 0.3)
- worker.signals.finished.connect(
- lambda: setattr(self, "_scrollSuppressed", False))
- QThreadPool.globalInstance().start(worker)
-
- if (event.angleDelta().y() < 0 and
- self.verticalScrollBar().value() == self.verticalScrollBar().maximum()):
- if (event.angleDelta().y() > -wheelDelta):
- if (self._trackPadAtMax == trackpadScrollLimit):
- self.parent.loadNextImage()
- self._trackPadAtMax = 0
- suppressScroll()
- return
- else:
- self._trackPadAtMax += 1
- elif (event.angleDelta().y() <= -wheelDelta):
- if (self._scrollAtMax == mouseScrollLimit):
- self.parent.loadNextImage()
- self._scrollAtMax = 0
- suppressScroll()
- return
- else:
- self._scrollAtMax += 1
-
- if (event.angleDelta().y() > 0 and
- self.verticalScrollBar().value() == self.verticalScrollBar().minimum()):
- if (event.angleDelta().y() < wheelDelta):
- if (self._trackPadAtMin == trackpadScrollLimit):
- self.parent.loadPrevImage()
- self._trackPadAtMin = 0
- suppressScroll()
- return
- else:
- self._trackPadAtMin += 1
- elif (event.angleDelta().y() >= wheelDelta):
- if (self._scrollAtMin == mouseScrollLimit):
- self.parent.loadPrevImage()
- self._scrollAtMin = 0
- suppressScroll()
- return
- else:
- self._scrollAtMin += 1
- QGraphicsView.wheelEvent(self, event)
-
- def mouseMoveEvent(self, event):
- pressedKey = QApplication.keyboardModifiers()
- panMode = pressedKey == Qt.ControlModifier or self._zoomPanMode
-
- if panMode:
- self.setDragMode(QGraphicsView.ScrollHandDrag)
- else:
- self.setDragMode(QGraphicsView.RubberBandDrag)
-
- BaseCanvas.mouseMoveEvent(self, event)
-
- def mouseDoubleClickEvent(self, event):
- self.currentScale = 1
- self.viewImage(self.currentScale)
- QGraphicsView.mouseDoubleClickEvent(self, event)
diff --git a/code/old/config.py b/code/old/config.py
deleted file mode 100644
index 604307c..0000000
--- a/code/old/config.py
+++ /dev/null
@@ -1,219 +0,0 @@
-"""
-Poricom
-Copyright (C) `2021-2022` ``
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-"""
-
-stylesheet_path = './assets/styles.qss'
-combobox_selected_index = {
- 'language': 0,
- 'orientation': 0,
- 'font_style': 0,
- 'font_size': 2,
-}
-picker_index = {
- 'language': 20,
- 'orientation': 21,
- 'font_style': 22,
- 'font_size': 23
-}
-cfg = {
- "IMAGE_EXTENSIONS": ["*.bmp", "*.gif", "*.jpg", "*.jpeg", "*.png",
- "*.pbm", "*.pgm", "*.ppm", "*.webp", "*.xbm", "*.xpm"],
-
- "LANGUAGE": [" Japanese", " Korean", " Chinese SIM", " Chinese TRA ", " English"],
- "ORIENTATION": [" Vertical", " Horizontal"],
- "LANG_PATH": "./assets/languages/",
-
- "FONT_STYLE": [" Poppins", " Arial", " Verdana", " Helvetica", " Times New Roman"],
- "FONT_SIZE": [" 12", " 14", " 16", " 20", " 24", " 32", " 40", " 56", " 72"],
-
- "SELECTED_INDEX": combobox_selected_index,
- "PICKER_INDEX": picker_index,
-
- "STYLES_PATH": "./assets/",
- "STYLES_DEFAULT": stylesheet_path,
-
- "NAV_VIEW_RATIO": [3,11],
- "NAV_ROOT": "./assets/images/",
-
- "NAV_FUNCS": {
- "path_changed": "view_image_from_fdialog",
- "nav_clicked": "view_image_from_explorer"
- },
-
- "LOGO": "./assets/images/icons/logo.ico",
- "HOME_IMAGE": "./assets/images/home.png",
-
- "RBN_HEIGHT": 2.4,
-
- "TBAR_ISIZE_REL": 0.1,
- "TBAR_ISIZE_MARGIN": 1.3,
-
- "TBAR_ICONS": "./assets/images/icons/",
- "TBAR_ICONS_LIGHT": "./assets/images/icons/",
- "TBAR_ICON_DEFAULT": "./assets/images/icons/default_icon.png",
-
- "TBAR_FUNCS": {
- "FILE": {
- "open_dir": {
- "help_title": "Open manga directory",
- "help_msg": "Open a directory containing images.",
- "path": "open_dir.png",
- "toggle": False,
- "align": "AlignLeft",
- "icon_h": 1.0,
- "icon_w": 1.0
- },
- "open_manga": {
- "help_title": "Open manga file",
- "help_msg": "Supports the following formats: cbr, cbz, pdf.",
- "path": "open_manga.png",
- "toggle": False,
- "align": "AlignLeft",
- "icon_h": 1.0,
- "icon_w": 1.0
- }
- },
- "VIEW": {
- "toggle_stylesheet": {
- "help_title": "Change theme",
- "help_msg": "Switch between light and dark mode.",
- "path": "toggle_stylesheet.png",
- "toggle": False,
- "align": "AlignLeft",
- "icon_h": 1.0,
- "icon_w": 1.0
- },
- "modify_font_settings": {
- "help_title": "Modify preview text",
- "help_msg": "Change font style and font size of preview text.",
- "path": "modify_font_settings.png",
- "toggle": False,
- "align": "AlignLeft",
- "icon_h": 1.0,
- "icon_w": 1.0
- },
- "fit_horizontally": {
- "help_title": "Fit image horizontally",
- "help_msg": "",
- "path": "fit_horizontally.png",
- "toggle": True,
- "align": "AlignLeft",
- "icon_h": 1.0,
- "icon_w": 1.0
- },
- "fit_vertically": {
- "help_title": "Fit image vertically",
- "help_msg": "",
- "path": "fit_vertically.png",
- "toggle": True,
- "align": "AlignLeft",
- "icon_h": 1.0,
- "icon_w": 1.0
- }
- },
- "SETTINGS": {
- "load_model": {
- "help_title": "Switch detection model",
- "help_msg": "Switch between MangaOCR and Tesseract models.",
- "path": "load_model.png",
- "toggle": True,
- "align": "AlignLeft",
- "icon_h": 1.0,
- "icon_w": 1.0
- },
- "modify_tesseract": {
- "help_title": "Tesseract settings",
- "help_msg": "Set the language and orientation for the \
- Tesseract model.",
- "path": "modify_tesseract.png",
- "toggle": False,
- "align": "AlignLeft",
- "icon_h": 1.0,
- "icon_w": 1.0
- },
- "toggle_logging": {
- "help_title": "Enable text logging",
- "help_msg": "Save detected text to a text file located in the \
- current project directory.",
- "path": "toggle_logging.png",
- "toggle": True,
- "align": "AlignLeft",
- "icon_h": 1.0,
- "icon_w": 1.0
- },
- "toggle_mouse_mode": {
- "help_title": "Change mouse behavior",
- "help_msg": "This will disable text detection. Turn this on \
- only if do not want to hold CTRL key to zoom and pan \
- on an image.",
- "path": "toggle_mouse_mode.png",
- "toggle": True,
- "align": "AlignLeft",
- "icon_h": 1.0,
- "icon_w": 1.0
- }
- }
- },
-
- "MODE_FUNCS": {
- "zoom_in": {
- "help_title": "Zoom in",
- "help_msg": "Hint: Double click the image to reset zoom.",
- "path": "zoom_in.png",
- "toggle": False,
- "align": "AlignRight",
- "icon_h": 0.45,
- "icon_w": 0.45
- },
- "zoom_out": {
- "help_title": "Zoom out",
- "help_msg": "Hint: Double click the image to reset zoom.",
- "path": "zoom_out.png",
- "toggle": False,
- "align": "AlignRight",
- "icon_h": 0.45,
- "icon_w": 0.45
- },
- "load_image_at_idx": {
- "help_title": "",
- "help_msg": "Jump to page",
- "path": "load_image_at_idx.png",
- "toggle": False,
- "align": "AlignRight",
- "icon_h": 0.45,
- "icon_w": 1.3
- },
- "load_prev_image": {
- "help_title": "",
- "help_msg": "Show previous image",
- "path": "load_prev_image.png",
- "toggle": False,
- "align": "AlignRight",
- "icon_h": 0.45,
- "icon_w": 0.6
- },
- "load_next_image": {
- "help_title": "",
- "help_msg": "Show next image",
- "path": "load_next_image.png",
- "toggle": False,
- "align": "AlignRight",
- "icon_h": 0.45,
- "icon_w": 0.6
- }
- }
-}
\ No newline at end of file
diff --git a/code/old/memory.py b/code/old/memory.py
deleted file mode 100644
index fc4781f..0000000
--- a/code/old/memory.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# TODO: Rewrite this as a Tracker object that will
-# save image paths, pixmaps of original images and
-# masks, button states, and window state
-# Use decorators
-
-class Tracker:
- pass
-
-from default import cfg
-from os import listdir
-from os.path import isfile, join, splitext, normpath
-
-img_index = 0
-img_paths = []
-mask_paths = []
-curr_dir = cfg["NAV_ROOT"]
-curr_img = cfg["HOME_IMAGE"]
-
-def get_img_path():
- #global curr_dir
- return curr_dir
-
-def set_img_path(path):
- global curr_dir, img_paths
- curr_dir = normpath(path)
- filelist = filter(lambda f: isfile(join(path, f)), listdir(path))
- img_paths = list(map(lambda p: normpath(join(path, p)),
- filter((lambda f: ('*'+splitext(f)[1]) in
- cfg["IMAGE_EXTENSIONS"]), filelist)))
-
-def get_img_list():
- #global curr_dir
- return img_paths
-
-def get_curr_img():
- #global curr_img
- return curr_img
-
-def get_prev_img():
- pass
-
-def set_curr_img(filepath):
- global curr_img
- curr_img = filepath
-
-def set_prev_img():
- pass
-
-def get_curr_mask():
- pass
-
-def get_prev_mask():
- pass
-
-def set_curr_mask():
- pass
-
-def set_prev_mask():
- pass
-
-def get_img_index():
- pass
\ No newline at end of file
diff --git a/code/old/ribbon.py b/code/old/ribbon.py
deleted file mode 100644
index 8bf17ca..0000000
--- a/code/old/ribbon.py
+++ /dev/null
@@ -1,120 +0,0 @@
-from PyQt5.QtWidgets import (QMainWindow, QApplication, QPushButton,
- QWidget, QAction, QTabWidget, QVBoxLayout, QGridLayout,
- QLabel, QHBoxLayout, QFileDialog)
-
-from PyQt5.QtGui import QIcon
-from PyQt5.QtCore import QSize, Qt, pyqtSignal, pyqtSlot
-
-import memory as mem
-from viewer import ImageViewer, ImageNavigator
-
-from default import cfg
-from os.path import exists
-
-class PMainWindow(QWidget):
- def __init__(self, parent=None):
- super(QWidget, self).__init__(parent)
- self.layout = QVBoxLayout(self)
-
- self.ribbon = QTabWidget()
- self.createRibbon()
- self.layout.addWidget(self.ribbon)
-
- self.img_viewer = ImageNavigator()
- self.layout.addWidget(self.img_viewer)
-
- def createRibbon(self):
- h = self.frameGeometry().height() * cfg["TBAR_ISIZE_REL"] * cfg["RBN_HEIGHT"]
- self.ribbon.setFixedHeight(h)
- for tab_name, tools in cfg["TBAR_FUNCS"].items():
- self.ribbon.addTab(Toolbar(parent=self, fxns=tools), tab_name)
-
- def update_window(self, mode=0):
- self.img_viewer.set_proj_path(mem.get_img_path())
-
- def open_dir(self):
- path = str(QFileDialog.getExistingDirectory(self, "Select Directory"))
- if path:
- mem.set_img_path(path)
- self.update_window()
-
- def save_img(self):
- print("Image saved to ", mem.get_img_path())
- pass
-
- def delete_img(self):
- print("Image deleted in ", mem.get_img_path())
- pass
-
- def get_mask(self):
- print("Generating mask for ", mem.get_img_path())
- pass
-
- def delete_text(self):
- print("Text deleted from mask ", mem.get_img_path())
- pass
-
- def edit_mask_(self):
- #TODO
- pass
-
- def edit_mask(self):
- # Connect the trigger signal to a slot.
- self.img_viewer.some_signal.connect(self.handle_trigger)
-
- # Emit the signal.
- self.img_viewer.some_signal.emit("1")
-
- @pyqtSlot(str)
- def handle_trigger(self, r):
- #print("I got a signal" + r)
- pass
-
- def compare_img(self):
- #self.img_viewer.mask_viewer.setHidden(
- # not self.img_viewer.mask_viewer.isHidden())
- pass
-
-class Toolbar(QWidget):
-
- acquire_index = pyqtSignal(int)
-
- def __init__(self, parent=None, fxns=None):
- super(QWidget, self).__init__()
- self.layout = QHBoxLayout(self)
- self.buttons = []
- self.parent = parent
-
- s = self.parent.frameGeometry().height() * cfg["TBAR_ISIZE_REL"]
- m = s * cfg["TBAR_ISIZE_MARGIN"]
- self.layout.setAlignment(Qt.AlignLeft)
- count = 0
- for fxn in fxns:
- icon = QIcon()
- path = cfg["TBAR_IMG_ASSETS"] + fxn + ".png"
- if (exists(path)):
- icon = QIcon(path)
- else: icon = QIcon(cfg["TBAR_ICON_IMG"])
-
- self.buttons.append(QPushButton(self))
- self.buttons[-1].setIcon(icon)
- self.buttons[-1].setIconSize(QSize(s,s))
- self.buttons[-1].setFixedSize(QSize(m,m))
- #if count == 0:
- # self.buttons.append(QPushButton(self))
- # self.buttons[-1].setIcon(QIcon("../assets/images/" + fxn + ".png"))
- # self.buttons[-1].setIconSize(QSize(s,s))
- # self.buttons[-1].setFixedSize(QSize(m,m))
- #r = cfg[fxn]["button_code"]
- #print(r)
- #self.buttons[-1].clicked.connect(lambda s=r: self.on_click(s))
- #count += 1
- #else:
- # self.buttons.append(QPushButton("", self))
- # self.buttons[-1].setFixedSize(QSize(m,m))
- self.buttons[-1].clicked.connect(getattr(self.parent, fxn))
- self.layout.addWidget(self.buttons[-1])
-
- @pyqtSlot(str)
- def on_click(self, index):
- print("hahahaha", index)
\ No newline at end of file
diff --git a/code/old/viewer.py b/code/old/viewer.py
deleted file mode 100644
index 5a8048c..0000000
--- a/code/old/viewer.py
+++ /dev/null
@@ -1,116 +0,0 @@
-from PyQt5.QtCore import Qt, QDir, pyqtSignal, pyqtSlot
-from PyQt5.QtGui import (QImage, QPixmap)
-from PyQt5.QtWidgets import (QLabel, QScrollArea, QSizePolicy)
-from PyQt5.QtWidgets import (QWidget, QFileSystemModel, QTreeView,
- QHBoxLayout)
-
-import memory as mem
-from default import cfg
-
-class ImageNavigator(QWidget):
-
- some_signal = pyqtSignal(str)
-
- def __init__(self, parent=None):
- super(QWidget, self).__init__(parent)
-
- _layout = QHBoxLayout(self)
- _layout.setContentsMargins(0,0,2,0)
-
- self.model = QFileSystemModel()
- self.init_fs_model()
-
- self.treeview = QTreeView()
- self.treeview.setModel(self.model)
- self.init_treeview()
- _layout.addWidget(self.treeview, cfg["NAV_VIEW_RATIO"][0])
-
- self.image_viewer = ImageViewer()
- _layout.addWidget(self.image_viewer, cfg["NAV_VIEW_RATIO"][1])
-
- self.mask_viewer = ImageViewer()
- _layout.addWidget(self.mask_viewer, cfg["NAV_VIEW_RATIO"][1])
- self.mask_viewer.setHidden(True)
-
- self.set_proj_path(mem.get_img_path())
-
- def init_fs_model(self):
- self.model.setFilter(QDir.Files)
- self.model.setNameFilterDisables(False)
- self.model.setNameFilters(cfg["IMAGE_EXTENSIONS"])
-
- self.model.directoryLoaded.connect(self.load_default_img)
- #self.model.rootPathChanged.connect(self.set_proj_path)
-
- def init_treeview(self):
- for i in range(1,4):
- self.treeview.hideColumn(i)
- self.treeview.setIndentation(5)
-
- self.treeview.clicked.connect(self.view_image_from_explorer)
-
- def view_image_from_explorer(self, index):
- fp = self.model.fileInfo(index).absoluteFilePath()
- mem.set_curr_img(fp)
- self.image_viewer.view_image()
-
- def view_image_from_toolbar(self, mode=0):
- fp = mem.get_curr_img()
- mem.set_curr_img(fp)
- self.image_viewer.view_image()
- pass
-
- def set_proj_path(self, path):
- if path is None:
- #TODO: Error Handling
- pass
- mem.set_img_path(path)
- self.treeview.setRootIndex(self.model.setRootPath(path))
-
- def load_default_img(self):
- fp = self.model.index(0, 0, self.model.index(self.model.rootPath()))
- mem.set_curr_img(self.model.rootPath()+"/"+self.model.data(fp))
- self.image_viewer.view_image()
-
-
-
-class ImageViewer(QScrollArea):
- def __init__(self, parent = None):
- super(QScrollArea, self).__init__(parent)
-
- self._img_label = QLabel()
- self.setWidget(self._img_label)
- self.init_img_label()
-
- self.setWidgetResizable(True)
- self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
- self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
-
- self.verticalScrollBar().valueChanged.connect(lambda idx: self.kekw(idx))
-
- def init_img_label(self):
- self._img_label.setContentsMargins(10,10,10,0)
-
- def view_image(self, filepath=None, q_image=None, mode=0):
-
- w = self.frameGeometry().width()
- h = self.frameGeometry().height()
-
- filepath = mem.get_curr_img()
- image = q_image
- if filepath:
- image = QImage(filepath)
- if image is None:
- #TODO: Error Handling
- return
- pixmap_img = QPixmap.fromImage(image)
- self._img_label.setPixmap(pixmap_img.scaledToWidth(
- w-20, Qt.SmoothTransformation))
- self._img_label.adjustSize()
-
- def resizeEvent(self, event):
- self.view_image()
- QScrollArea.resizeEvent(self, event)
-
- def kekw(self,idx):
- print(idx)
\ No newline at end of file
diff --git a/code/utils/config.py b/code/utils/config.py
deleted file mode 100644
index a283705..0000000
--- a/code/utils/config.py
+++ /dev/null
@@ -1,53 +0,0 @@
-"""
-Poricom Configuration Utilities
-
-Copyright (C) `2021-2022` ``
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-"""
-
-import toml
-config = toml.load("./utils/config.toml")
-
-
-def saveOnClose(data, config="utils/config.toml"):
- with open(config, 'w') as fh:
- toml.dump(data, fh)
-
-
-def editConfig(index, replacementText, config="utils/config.toml"):
- data = toml.load(config)
- data[index] = replacementText
- with open(config, 'w') as fh:
- toml.dump(data, fh)
-
-
-def editSelectionConfig(index, cBoxName, config="utils/config.toml"):
- data = toml.load(config)
- data["SELECTED_INDEX"][cBoxName] = index
- with open(config, 'w') as fh:
- toml.dump(data, fh)
-
-
-def editStylesheet(index, replacementText):
- sheetLight = './assets/styles.qss'
- sheetDark = './assets/styles-dark.qss'
- with open(sheetLight, 'r') as slFh, open(sheetDark, 'r') as sdFh:
- lineLight = slFh.readlines()
- linesDark = sdFh.readlines()
- lineLight[index] = replacementText
- linesDark[index] = replacementText
- with open(sheetLight, 'w') as slFh, open(sheetDark, 'w') as sdFh:
- slFh.writelines(lineLight)
- sdFh.writelines(linesDark)
diff --git a/code/utils/config.toml b/code/utils/config.toml
deleted file mode 100644
index 7c21217..0000000
--- a/code/utils/config.toml
+++ /dev/null
@@ -1,240 +0,0 @@
-# Poricom Default Configuration File
-#
-# Copyright (C) `2021-2022` ``
-#
-# This program is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program. If not, see .
-
-# Lists
-IMAGE_EXTENSIONS = [ "*.bmp", "*.gif", "*.jpg", "*.jpeg", "*.png", "*.pbm", "*.pgm", "*.ppm", "*.webp", "*.xbm", "*.xpm",]
-LANGUAGE = [ " Japanese", " Korean", " Chinese SIM", " Chinese TRA ", " English",]
-ORIENTATION = [ " Vertical", " Horizontal",]
-FONT_STYLE = [ " Helvetica", " Poppins", " Arial", " Verdana", " Times New Roman",]
-FONT_SIZE = [ " 12", " 14", " 16", " 20", " 24", " 32", " 40", " 56", " 72",]
-IMAGE_SCALING= [ " Fit to Width", " Fit to Height", " Fit to Screen",]
-MODIFIER = [ " Ctrl", " Shift", " Alt", " Ctrl+Alt", " Shift+Alt", " Shift+Ctrl", " Shift+Alt+Ctrl", " No Modifier"]
-
-# Filepath
-STYLES_PATH = "./assets/"
-NAV_ROOT = "./assets/images/"
-TBAR_ICONS = "./assets/images/icons/"
-TBAR_ICONS_LIGHT = "./assets/images/icons/"
-LANG_PATH = "./assets/languages/"
-
-STYLES_DEFAULT = "./assets/styles.qss"
-LOGO = "./assets/images/icons/logo.ico"
-HOME_IMAGE = "./assets/images/home.png"
-ABOUT_IMAGE = "./assets/images/about.png"
-TBAR_ICON_DEFAULT = "./assets/images/icons/default_icon.png"
-
-# Sizes
-RBN_HEIGHT = 2.4
-TBAR_ISIZE_REL = 0.1
-TBAR_ISIZE_MARGIN = 1.3
-NAV_VIEW_RATIO = [ 3, 11,]
-
-# Mode
-VIEW_IMAGE_MODE = 0
-SPLIT_VIEW_MODE = false
-
-[SELECTED_INDEX]
-language = 0
-orientation = 0
-fontStyle = 0
-fontSize = 2
-imageScaling = 0
-modifier = 2
-
-[PICKER_INDEX]
-language = 49
-orientation = 50
-fontStyle = 51
-fontSize = 52
-imageScaling = 53
-modifier = 54
-
-[SHORTCUT]
-captureExternal = "Alt+Q"
-captureExternalKey = "Q"
-captureExternalTip = "This will minimize the app and perform OCR on the current screen. Alternatively, you may use the shortcut: "
-
-[NAV_FUNCS]
-pathChanged = "viewImageFromFDialog"
-navClicked = "viewImageFromExplorer"
-
-# Ribbon buttons (always on)
-[MODE_FUNCS]
-
- [MODE_FUNCS.zoomIn]
- helpTitle = "Zoom in"
- helpMsg = "Hint: Double click the image to reset zoom."
- path = "zoomIn.png"
- toggle = false
- align = "AlignRight"
- iconH = 0.45
- iconW = 0.45
-
- [MODE_FUNCS.zoomOut]
- helpTitle = "Zoom out"
- helpMsg = "Hint: Double click the image to reset zoom."
- path = "zoomOut.png"
- toggle = false
- align = "AlignRight"
- iconH = 0.45
- iconW = 0.45
-
- [MODE_FUNCS.loadImageAtIndex]
- helpTitle = ""
- helpMsg = "Jump to page"
- path = "loadImageAtIndex.png"
- toggle = false
- align = "AlignRight"
- iconH = 0.45
- iconW = 1.3
-
- [MODE_FUNCS.loadPrevImage]
- helpTitle = ""
- helpMsg = "Show previous image"
- path = "loadPrevImage.png"
- toggle = false
- align = "AlignRight"
- iconH = 0.45
- iconW = 0.6
-
- [MODE_FUNCS.loadNextImage]
- helpTitle = ""
- helpMsg = "Show next image"
- path = "loadNextImage.png"
- toggle = false
- align = "AlignRight"
- iconH = 0.45
- iconW = 0.6
-
-# Ribbon buttons
-[TBAR_FUNCS]
-
- [TBAR_FUNCS.FILE]
-
- [TBAR_FUNCS.FILE.openDir]
- helpTitle = "Open manga directory"
- helpMsg = "Open a directory containing images."
- path = "openDir.png"
- toggle = false
- align = "AlignLeft"
- iconH = 1.0
- iconW = 1.0
-
- [TBAR_FUNCS.FILE.openManga]
- helpTitle = "Open manga file"
- helpMsg = "Supports the following formats: cbr, cbz, pdf."
- path = "openManga.png"
- toggle = false
- align = "AlignLeft"
- iconH = 1.0
- iconW = 1.0
-
- [TBAR_FUNCS.FILE.captureExternalHelper]
- helpTitle = "External capture"
- helpMsg = "This will minimize the app and perform OCR on the current screen. Alternatively, you may use the shortcut Alt+Q."
- path = "captureExternalHelper.png"
- toggle = false
- align = "AlignLeft"
- iconH = 1.0
- iconW = 1.0
-
- [TBAR_FUNCS.VIEW]
-
- [TBAR_FUNCS.VIEW.toggleStylesheet]
- helpTitle = "Change theme"
- helpMsg = "Switch between light and dark mode."
- path = "toggleStylesheet.png"
- toggle = false
- align = "AlignLeft"
- iconH = 1.0
- iconW = 1.0
-
- [TBAR_FUNCS.VIEW.modifyFontSettings]
- helpTitle = "Modify preview text"
- helpMsg = "Change font style and font size of preview text."
- path = "modifyFontSettings.png"
- toggle = false
- align = "AlignLeft"
- iconH = 1.0
- iconW = 1.0
-
- [TBAR_FUNCS.VIEW.toggleSplitView]
- helpTitle = "Turn on split view"
- helpMsg = "View two images at once."
- path = "toggleSplitView.png"
- toggle = true
- align = "AlignLeft"
- iconH = 1.0
- iconW = 1.0
-
- [TBAR_FUNCS.VIEW.scaleImage]
- helpTitle = "Adjust image scaling"
- helpMsg = "Fit an image according to the available options: fit to width, fit to height, fit to screen"
- path = "scaleImage.png"
- toggle = false
- align = "AlignLeft"
- iconH = 1.0
- iconW = 1.0
-
- [TBAR_FUNCS.CONTROLS]
-
- [TBAR_FUNCS.CONTROLS.toggleMouseMode]
- helpTitle = "Change mouse behavior"
- helpMsg = "This will disable text detection. Turn this on only if do not want to hold CTRL key to zoom and pan on an image."
- path = "toggleMouseMode.png"
- toggle = true
- align = "AlignLeft"
- iconH = 1.0
- iconW = 1.0
-
- [TBAR_FUNCS.CONTROLS.modifyHotkeys]
- helpTitle = "Remap hotkeys"
- helpMsg = "Change shortcut for external captures."
- path = "modifyHotkeys.png"
- toggle = false
- align = "AlignLeft"
- iconH = 1.0
- iconW = 1.0
-
- [TBAR_FUNCS.MISC]
-
- [TBAR_FUNCS.MISC.loadModel]
- helpTitle = "Switch detection model"
- helpMsg = "Switch between MangaOCR and Tesseract models."
- path = "loadModel.png"
- toggle = true
- align = "AlignLeft"
- iconH = 1.0
- iconW = 1.0
-
- [TBAR_FUNCS.MISC.modifyTesseract]
- helpTitle = "Tesseract settings"
- helpMsg = "Set the language and orientation for the Tesseract model."
- path = "modifyTesseract.png"
- toggle = false
- align = "AlignLeft"
- iconH = 1.0
- iconW = 1.0
-
- [TBAR_FUNCS.MISC.toggleLogging]
- helpTitle = "Enable text logging"
- helpMsg = "Save detected text to a text file located in the current project directory."
- path = "toggleLogging.png"
- toggle = true
- align = "AlignLeft"
- iconH = 1.0
- iconW = 1.0
\ No newline at end of file
diff --git a/code/utils/image_io.py b/code/utils/image_io.py
deleted file mode 100644
index fe98673..0000000
--- a/code/utils/image_io.py
+++ /dev/null
@@ -1,96 +0,0 @@
-"""
-Poricom Image Processing Utility
-
-Copyright (C) `2021-2022` ``
-
-This program is free software: you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program. If not, see .
-"""
-
-from io import BytesIO
-from os.path import splitext, basename
-from pathlib import Path
-
-from PyQt5.QtCore import QBuffer
-from PyQt5.QtGui import QGuiApplication
-from tesserocr import PyTessBaseAPI
-from PIL import Image
-import zipfile
-import rarfile
-import pdf2image
-
-from utils.config import config
-
-
-def mangaFileToImageDir(filepath):
- extractPath, extension = splitext(filepath)
- cachePath = f"./poricom_cache/{basename(extractPath)}"
-
- if extension in [".cbz", ".zip"]:
- with zipfile.ZipFile(filepath, 'r') as zipRef:
- zipRef.extractall(cachePath)
-
- rarfile.UNRAR_TOOL = "utils/unrar.exe"
- if extension in [".cbr", ".rar"]:
- with rarfile.RarFile(filepath) as zipRef:
- zipRef.extractall(cachePath)
-
- if extension in [".pdf"]:
- try:
- images = pdf2image.convert_from_path(filepath)
- except pdf2image.exceptions.PDFInfoNotInstalledError:
- images = pdf2image.convert_from_path(
- filepath, poppler_path="poppler/Library/bin")
- for i in range(len(images)):
- filename = basename(extractPath)
- Path(cachePath).mkdir(parents=True, exist_ok=True)
- images[i].save(
- f"{cachePath}/{i+1}_{filename}.png", 'PNG')
-
- return cachePath
-
-
-def pixboxToText(pixmap, lang="jpn_vert", model=None):
-
- buffer = QBuffer()
- buffer.open(QBuffer.ReadWrite)
- pixmap.save(buffer, "PNG")
- bytes = BytesIO(buffer.data())
-
- if bytes.getbuffer().nbytes == 0:
- return
-
- pillowImage = Image.open(bytes)
- text = ""
-
- if model is not None:
- text = model(pillowImage)
-
- # PSM = 1 works most of the time except on smaller bounding boxes.
- # By smaller, we mean textboxes with less text. Usually these
- # boxes have at most one vertical line of text.
- else:
- with PyTessBaseAPI(path=config["LANG_PATH"], lang=lang, oem=1, psm=1) as api:
- api.SetImage(pillowImage)
- text = api.GetUTF8Text()
-
- return text.strip()
-
-
-def logText(text, mode=False, path="."):
- clipboard = QGuiApplication.clipboard()
- clipboard.setText(text)
-
- if mode:
- with open(path, 'a', encoding="utf-8") as fh:
- fh.write(text + "\n")
diff --git a/environment/base.yaml b/environment/base.yaml
new file mode 100644
index 0000000..22e63ef
--- /dev/null
+++ b/environment/base.yaml
@@ -0,0 +1,22 @@
+name: poricom-py39
+
+channels:
+ - conda-forge
+ - defaults
+
+dependencies:
+ - python=3.9
+ - pip
+ - poppler
+ - tesserocr
+ - pip:
+ - argostranslate
+ - cutlet
+ - huggingface-hub==0.7.0
+ - manga-ocr
+ - pdf2image
+ - pillow
+ - pyqt5
+ - pyqtkeybind
+ - rarfile
+ - stringcase
diff --git a/environment/build.yaml b/environment/build.yaml
new file mode 100644
index 0000000..dddabf4
--- /dev/null
+++ b/environment/build.yaml
@@ -0,0 +1,9 @@
+name: poricom-py39
+
+channels:
+ - conda-forge
+ - defaults
+
+dependencies:
+ - pip:
+ - pyinstaller==4.10
diff --git a/environment/dev.yaml b/environment/dev.yaml
new file mode 100644
index 0000000..78f1ddb
--- /dev/null
+++ b/environment/dev.yaml
@@ -0,0 +1,9 @@
+name: poricom-py39
+
+channels:
+ - conda-forge
+ - defaults
+
+dependencies:
+ - pip:
+ - black
diff --git a/requirements.txt b/requirements.txt
deleted file mode 100644
index e1de2d8..0000000
--- a/requirements.txt
+++ /dev/null
@@ -1,7 +0,0 @@
-pyqt5~=5.15.6
-pillow~=9.0.1
-tesserocr~=2.5.1
-manga-ocr~=0.1.5
-pyqtkeybind~=0.0.9
-rarfile~=4.0
-pdf2image~=1.16.0
\ No newline at end of file