Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/YaoZeyuan/stablog
Browse files Browse the repository at this point in the history
  • Loading branch information
yaozeyuan001 committed May 27, 2021
2 parents 50a267f + fc347e0 commit 770b12c
Show file tree
Hide file tree
Showing 9 changed files with 358 additions and 98 deletions.
2 changes: 1 addition & 1 deletion .npmrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ fse_binary_host_mirror="https://npm.taobao.org/mirrors/fsevents"
sharp_binary_host="https://npm.taobao.org/mirrors/sharp"
sharp_libvips_binary_host="https://npm.taobao.org/mirrors/sharp-libvips"
# 配置msvs版本
msvs_version=2019
msvs_version=2015
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
"windows": {
"runtimeExecutable": "${workspaceFolder}/node_modules/.bin/electron.cmd"
},
"args": ["."]
"args": [".", "--debug"]
},
{
"type": "node",
Expand Down
2 changes: 1 addition & 1 deletion .yarnrc
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ fse_binary_host_mirror "https://npm.taobao.org/mirrors/fsevents"
sharp_binary_host "https://npm.taobao.org/mirrors/sharp"
sharp_libvips_binary_host "https://npm.taobao.org/mirrors/sharp-libvips"
# 配置msvs版本
msvs_version 2019
msvs_version 2015
8 changes: 8 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 3.2.0

1. 修复 mac 上无法渲染 pdf 的问题
1. mac 加载本地网页时必须加`file://`前缀
2. 对高分屏用户, 截取出的图片是正常分辨率 n 倍, 需手工对原图进行一次还原
2. 将单卷微博总量降低到 5000, 避免 pdf 生成失败
3. 限制图片最大高度为 30000px, 网页长度超过 30000 则拆分为多张图片, 避免由于网页过长导致渲染失败

# 3.1.0

1. 修复无法识别形如`https://weibo.com/world2049`类主页地址的问题
Expand Down
2 changes: 1 addition & 1 deletion doc/高级功能.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
6. 电子书拆分规则
1. 每年/月/x 条微博 输出为一本电子书 或不进行拆分, 将所有微博输出为一本电子书.
2. 选项目的是为解决电子书体积过大问题. 如果单本电子书内微博总数超出配置值, 将会分为多卷输出
3. 单本电子书中, 微博数量不能超过 10000 条, 超过则会强制自动拆分(由于 Node.js 本身限制, 超过 10000 条后, 容易由于内存溢出导致在输出阶段程序 crash 退出. 理论上添加`--max-old-space-size=8192`命令可以解决该问题, 但根据实测情况, 该选项在编译后并没有效果)
3. 单本电子书中, 微博数量不能超过 5000 条, 超过则会强制自动拆分(由于 Node.js 本身限制, 超过 5000 条后, 容易由于内存溢出导致在输出阶段程序 crash 退出. 理论上添加`--max-old-space-size=8192`命令可以解决该问题, 但根据实测情况, 该选项在编译后并没有效果)
4. 默认不进行拆分

## 数据导入导出
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "stablog",
"version": "3.1.0",
"version": "3.2.0",
"description": "稳部落. 专业备份微blog, 老铁, 稳!",
"repository": {
"type": "git",
Expand Down
91 changes: 89 additions & 2 deletions src/command/debug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,15 @@ import Base from '~/src/command/base'
import MBlog from '~/src/model/mblog'
import MblogUser from '~/src/model/mblog_user'
import fs from 'fs'
import path from 'path'
// import path from 'path'
// import jsPDF from '~/src/library/pdf/jspdf.node.js'
// import { BrowserWindow } from 'electron'
// import CommonUtil from '~/src/library/util/common'
// import { TypeTransConfigPackageList } from './generate/trans_config'
// import imageSize from 'image-size'
import imageSize from 'image-size'
import * as mozjpeg from "mozjpeg-js"
import sharp from "sharp"

// const outputUri = path.resolve('F:/www/share/github/stablog/缓存文件/pdf_debug_1.pdf')
// /**
Expand Down Expand Up @@ -37,7 +40,91 @@ class CommandDebug extends Base {
}

async execute() {
await MblogUser.asyncGetUserList()
const Const_Max_Webview_Render_Height_Px = 5000
const Const_Default_Webview_Width = 760;


let inputList: any[] = []
let totalImgCount = 16;
let baseUri = path.resolve("F:/www/share/github/win_stablog/缓存文件/test_img/测试图片_2018-08-04 07:46:07_4269199607885116_")
for (let imgIndex = 0; imgIndex < totalImgCount; imgIndex++) {
let filename = `${baseUri}${imgIndex}.jpg`
let content = fs.readFileSync(filename)
inputList.push({
input: content,
top: Const_Max_Webview_Render_Height_Px * imgIndex,
left: 0,
})
}

let mergeImg = sharp({
create: {
width: Const_Default_Webview_Width,
height: Const_Max_Webview_Render_Height_Px * totalImgCount,
channels: 4,
background: {
r: 255, g: 255, b: 255, alpha: 1,
},
}
}).png({
// "force": false,
})
mergeImg.composite(
inputList
)

let pngContent = await mergeImg.toBuffer().catch(e => {
this.log("mergeImg error => ", e)
return new Buffer("")
})

let outputPngImage = baseUri + 'output_all_png.png'
fs.writeFileSync(outputPngImage, pngContent)
// let outputImage_v2 = baseUri + 'output_all_jpg.jpg'
// let a = await Jimp.read(pngContent)
// let raw_jpgContent = await a.writeAsync(outputImage_v2)
// fs.writeFileSync(outputImage_v2, raw_jpgContent)
// let outputImage_v3 = baseUri + 'output_all_tiny_jpg.jpg'
// let out = mozjpeg.encode(raw_jpgContent, {
// //处理质量 百分比
// quality: 80
// });
// let d = out.data
// fs.writeFileSync(outputImage_v3, d)


// await images(jpgContent).save(outputImage, "jpeg")


// let imgSize = imageSize.imageSize(jpgContent)
// console.log({
// width: imgSize.width as number,
// height: imgSize.height as number,
// })
// let result = await sharp({
// create: {
// width: 760,
// height: 60000,
// channels: 4,
// background: {
// r: 255, g: 255, b: 255, alpha: 1,
// },
// }
// })
// .png({
// "colors":
// "compressionLevel": 9,
// })
// .toBuffer()
// .catch(e => {
// console.log(e)
// })
fs.writeFileSync(`${baseUri}final.jpg`, pngContent)


// await MblogUser.asyncGetUserList()


// let configUri = path.resolve("F:/www/share/github/stablog/缓存文件/pdf_html_config.json")
// let content = fs.readFileSync(configUri).toString()

Expand Down
Loading

0 comments on commit 770b12c

Please sign in to comment.